You've already forked linux-packaging-mono
Imported Upstream version 4.8.0.459
Former-commit-id: 2a5b9df2014f72665850c7f885e7aed54704a53a
This commit is contained in:
parent
a355c1b831
commit
e5cd25ff4f
@ -1,5 +1,5 @@
|
||||
//
|
||||
// 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>
|
||||
@ -38,8 +38,8 @@ using System.Text;
|
||||
|
||||
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
|
||||
{
|
||||
@ -50,7 +50,6 @@ namespace Mono.Tools
|
||||
static string inputFile;
|
||||
static bool quiet;
|
||||
static bool userStore;
|
||||
static bool btlsStore = false;
|
||||
|
||||
static X509Certificate DecodeCertificate (string s)
|
||||
{
|
||||
@ -116,13 +115,26 @@ namespace Mono.Tools
|
||||
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);
|
||||
@ -156,7 +168,6 @@ namespace Mono.Tools
|
||||
}
|
||||
}
|
||||
WriteLine ("Import process completed.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static string Thumbprint (string algorithm, X509Certificate certificate)
|
||||
@ -179,8 +190,7 @@ namespace Mono.Tools
|
||||
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]);
|
||||
|
Reference in New Issue
Block a user