[cert-sync] Don't import into BTLS store if BTLS is not available (#4475)
authorAlexander Köplinger <alex.koeplinger@outlook.com>
Mon, 6 Mar 2017 11:06:55 +0000 (12:06 +0100)
committerGitHub <noreply@github.com>
Mon, 6 Mar 2017 11:06:55 +0000 (12:06 +0100)
Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=53015

mcs/tools/security/cert-sync.cs

index b7b77f8f7660c78044a0fce67e6a2255a356946e..cc4355e4193212fd2ece61f4e1c66287431bba62 100644 (file)
@@ -119,15 +119,19 @@ namespace Mono.Tools
                        if (userStore) {
                                WriteLine ("Importing into legacy user store:");
                                ImportToStore (roots, X509StoreManager.CurrentUser.TrustedRoot);
-                               WriteLine ("");
-                               WriteLine ("Importing into BTLS user store:");
-                               ImportToStore (roots, X509StoreManager.NewCurrentUser.TrustedRoot);
+                               if (Mono.Security.Interface.MonoTlsProviderFactory.IsProviderSupported ("btls")) {
+                                       WriteLine ("");
+                                       WriteLine ("Importing into BTLS user store:");
+                                       ImportToStore (roots, X509StoreManager.NewCurrentUser.TrustedRoot);
+                               }
                        } else {
                                WriteLine ("Importing into legacy system store:");
                                ImportToStore (roots, X509StoreManager.LocalMachine.TrustedRoot);
-                               WriteLine ("");
-                               WriteLine ("Importing into BTLS system store:");
-                               ImportToStore (roots, X509StoreManager.NewLocalMachine.TrustedRoot);
+                               if (Mono.Security.Interface.MonoTlsProviderFactory.IsProviderSupported ("btls")) {
+                                       WriteLine ("");
+                                       WriteLine ("Importing into BTLS system store:");
+                                       ImportToStore (roots, X509StoreManager.NewLocalMachine.TrustedRoot);
+                               }
                        }
 
                        return 0;