static void AddUserStore(MonoBtlsX509Store store) { var userPath = MonoBtlsX509StoreManager.GetStorePath(MonoBtlsX509StoreType.UserTrustedRoots); if (Directory.Exists(userPath)) { store.AddDirectoryLookup(userPath, MonoBtlsX509FileType.PEM); } }
static void AddMachineStore(MonoBtlsX509Store store) { var machinePath = MonoBtlsX509StoreManager.GetStorePath(MonoBtlsX509StoreType.MachineTrustedRoots); if (Directory.Exists(machinePath)) { store.AddDirectoryLookup(machinePath, MonoBtlsX509FileType.PEM); } }
internal static void SetupCertificateStore(MonoBtlsX509Store store) { #if MONODROID store.SetDefaultPaths(); store.AddAndroidLookup(); #else var userPath = MonoBtlsX509StoreManager.GetStorePath(MonoBtlsX509StoreType.UserTrustedRoots); if (Directory.Exists(userPath)) { store.AddDirectoryLookup(userPath, MonoBtlsX509FileType.PEM); } var machinePath = MonoBtlsX509StoreManager.GetStorePath(MonoBtlsX509StoreType.MachineTrustedRoots); if (Directory.Exists(machinePath)) { store.AddDirectoryLookup(machinePath, MonoBtlsX509FileType.PEM); } #endif }
internal static void SetupCertificateStore(MonoBtlsX509Store store, MonoTlsSettings settings, bool server) { /* * In server-mode, we only add certificates which are explicitly trusted via * MonoTlsSettings.TrustAnchors. * * MonoTlsSettings.CertificateSearchPaths is ignored on Android. * */ #if MONODROID AddTrustedRoots(store, settings, server); if (!server) { SetupDefaultCertificateStore(store); } return; #else if (server || settings?.CertificateSearchPaths == null) { AddTrustedRoots(store, settings, server); if (!server) { SetupDefaultCertificateStore(store); } return; } foreach (var path in settings.CertificateSearchPaths) { switch (path) { case "@default": AddTrustedRoots(store, settings, server); AddUserStore(store); AddMachineStore(store); break; case "@trusted": AddTrustedRoots(store, settings, server); break; case "@user": AddUserStore(store); break; case "@machine": AddMachineStore(store); break; default: if (path.StartsWith("@pem:")) { var realPath = path.Substring(5); if (Directory.Exists(realPath)) { store.AddDirectoryLookup(realPath, MonoBtlsX509FileType.PEM); } break; } else if (path.StartsWith("@der:")) { var realPath = path.Substring(5); if (Directory.Exists(realPath)) { store.AddDirectoryLookup(realPath, MonoBtlsX509FileType.ASN1); } break; } throw new NotSupportedException(string.Format("Invalid item `{0}' in MonoTlsSettings.CertificateSearchPaths.", path)); } } #endif }
internal static void SetupCertificateStore (MonoBtlsX509Store store) { #if MONODROID store.SetDefaultPaths (); store.AddAndroidLookup (); #else var userPath = MonoBtlsX509StoreManager.GetStorePath (MonoBtlsX509StoreType.UserTrustedRoots); if (Directory.Exists (userPath)) store.AddDirectoryLookup (userPath, MonoBtlsX509FileType.PEM); var machinePath = MonoBtlsX509StoreManager.GetStorePath (MonoBtlsX509StoreType.MachineTrustedRoots); if (Directory.Exists (machinePath)) store.AddDirectoryLookup (machinePath, MonoBtlsX509FileType.PEM); #endif }
internal static void SetupCertificateStore(MonoBtlsX509Store store, MonoTlsSettings settings, bool server) { if (settings?.CertificateSearchPaths == null) { AddTrustedRoots(store, settings, server); } #if MONODROID SetupCertificateStore(store); return; #else if (settings?.CertificateSearchPaths == null) { SetupCertificateStore(store); return; } foreach (var path in settings.CertificateSearchPaths) { if (string.Equals(path, "@default", StringComparison.Ordinal)) { AddTrustedRoots(store, settings, server); AddUserStore(store); AddMachineStore(store); } else if (string.Equals(path, "@user", StringComparison.Ordinal)) { AddUserStore(store); } else if (string.Equals(path, "@machine", StringComparison.Ordinal)) { AddMachineStore(store); } else if (string.Equals(path, "@trusted", StringComparison.Ordinal)) { AddTrustedRoots(store, settings, server); } else if (path.StartsWith("@pem:", StringComparison.Ordinal)) { var realPath = path.Substring(5); if (Directory.Exists(realPath)) { store.AddDirectoryLookup(realPath, MonoBtlsX509FileType.PEM); } } else if (path.StartsWith("@der:", StringComparison.Ordinal)) { var realPath = path.Substring(5); if (Directory.Exists(realPath)) { store.AddDirectoryLookup(realPath, MonoBtlsX509FileType.ASN1); } } else { if (Directory.Exists(path)) { store.AddDirectoryLookup(path, MonoBtlsX509FileType.PEM); } } } #endif }