//
-// cert-sync.cs: Import the root certificates from Linux SSL store into Mono
+// cert-sync.cs: Import the root certificates from a certificate store into Mono
//
// Authors:
// Sebastien Pouliot <sebastien@ximian.com>
using Mono.Security.X509;
-[assembly: AssemblyTitle ("Linux Cert Store Sync")]
-[assembly: AssemblyDescription ("Synchronize local certs with certs from local Linux trust store.")]
+[assembly: AssemblyTitle ("Mono Certificate Store Sync")]
+[assembly: AssemblyDescription ("Populate Mono certificate store from a concatenated list of certificates.")]
namespace Mono.Tools
{
static string inputFile;
static bool quiet;
static bool userStore;
- static bool btlsStore = false;
static X509Certificate DecodeCertificate (string s)
{
WriteLine ("No certificates were found.");
return 0;
}
-
- X509Stores stores;
- if (userStore)
- stores = btlsStore ? X509StoreManager.NewCurrentUser : X509StoreManager.CurrentUser;
- else
- stores = btlsStore ? X509StoreManager.NewLocalMachine : X509StoreManager.LocalMachine;
- X509Store store = stores.TrustedRoot;
+
+ 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);
+ } else {
+ WriteLine ("Importing into legacy system store:");
+ ImportToStore (roots, X509StoreManager.LocalMachine.TrustedRoot);
+ WriteLine ("");
+ WriteLine ("Importing into BTLS system store:");
+ ImportToStore (roots, X509StoreManager.NewLocalMachine.TrustedRoot);
+ }
+
+ return 0;
+ }
+
+ static void ImportToStore (X509CertificateCollection roots, X509Store store)
+ {
X509CertificateCollection trusted = store.Certificates;
int additions = 0;
WriteLine ("I already trust {0}, your new list has {1}", trusted.Count, roots.Count);
}
}
WriteLine ("Import process completed.");
- return 0;
}
static string Thumbprint (string algorithm, X509Certificate certificate)
case "--user":
userStore = true;
break;
- case "--btls":
- btlsStore = true;
+ case "--btls": // we always import to the btls store too now, keep for compat
break;
default:
WriteLine ("Unknown option '{0}'.", args[i]);