improve detection of usable KeyChain (#40163)
authorTomas Weinfurt <tweinfurt@yahoo.com>
Fri, 9 Aug 2019 14:17:43 +0000 (07:17 -0700)
committerViktor Hofer <viktor.hofer@microsoft.com>
Tue, 3 Sep 2019 15:40:00 +0000 (17:40 +0200)
* improve detection of usable KeyChain

* add hint to user for errSecInteractionNotAllowed

src/System.Security.Cryptography.X509Certificates/tests/X509StoreMutableTests.OSX.cs

index 82e3d5b..5125098 100644 (file)
@@ -21,6 +21,13 @@ namespace System.Security.Cryptography.X509Certificates.Tests
             catch (CryptographicException e)
             {
                 const int errSecWrPerm = -61;
+                const int errSecInteractionNotAllowed = -25308;
+
+                if (e.HResult == errSecInteractionNotAllowed)
+                {
+                    Console.WriteLine("Run 'security unlock-keychain' to make tests runable.");
+                    return false;
+                }
 
                 if (e.HResult == errSecWrPerm)
                 {