private void LoadCertificateAuthorities() { _certificateAuthorities.Clear(); // load core CAs and custom CAs foreach (var ca in CertificateAuthority.CoreCertificateAuthorities) { _certificateAuthorities.TryAdd(ca.Id, ca); } try { var customCAs = SettingsManager.GetCustomCertificateAuthorities(); foreach (var ca in customCAs) { _certificateAuthorities.TryAdd(ca.Id, ca); } } catch (Exception exp) { // failed to load custom CAs _serviceLog.Error(exp.Message); } }
public async Task <ActionResult> RemoveCertificateAuthority(string id) { var customCAs = SettingsManager.GetCustomCertificateAuthorities(); var customCa = customCAs.FirstOrDefault(c => c.Id == id); if (customCa != null) { customCAs.Remove(customCa); if (SettingsManager.SaveCustomCertificateAuthorities(customCAs)) { return(new ActionResult("OK", true)); } } return(await Task.FromResult(new ActionResult("An error occurred saving the updated Certificate Authorities list.", false))); }
public async Task <ActionResult> UpdateCertificateAuthority(CertificateAuthority certificateAuthority) { try { if (_certificateAuthorities.Any(c => c.Key == certificateAuthority.Id && c.Value.IsCustom == false)) { // can't modify built in CAs return(new ActionResult("Default Certificate Authorities cannot be modified.", false)); } var customCAs = SettingsManager.GetCustomCertificateAuthorities(); var customCa = customCAs.FirstOrDefault(c => c.Id == certificateAuthority.Id); if (customCa != null) { // replace customCAs.Remove(customCa); customCAs.Add(certificateAuthority); _certificateAuthorities.TryUpdate(certificateAuthority.Id, certificateAuthority, customCa); } else { // add customCAs.Add(certificateAuthority); _certificateAuthorities.TryAdd(certificateAuthority.Id, certificateAuthority); } //store updated CAs if (SettingsManager.SaveCustomCertificateAuthorities(customCAs)) { return(new ActionResult("OK", true)); } } catch (Exception exp) { // failed to load custom CAs _serviceLog.Error(exp.Message); } return(await Task.FromResult(new ActionResult("An error occurred saving the updated Certificate Authorities list.", false))); }
public CertifyManager() { var serverConfig = SharedUtils.ServiceConfigManager.GetAppServiceConfig(); SettingsManager.LoadAppSettings(); InitLogging(serverConfig); Util.SetSupportedTLSVersions(); _itemManager = new ItemManager(); _credentialsManager = new CredentialsManager(); _serverProvider = (ICertifiedServer) new ServerProviderIIS(); _progressResults = new ObservableCollection <RequestProgressState>(); _pluginManager = new PluginManager(); _pluginManager.LoadPlugins(new List <string> { "Licensing", "DashboardClient", "DeploymentTasks", "CertificateManagers" }); // load core CAs and custom CAs foreach (var ca in CertificateAuthority.CoreCertificateAuthorities) { _certificateAuthorities.TryAdd(ca.Id, ca); } try { var customCAs = SettingsManager.GetCustomCertificateAuthorities(); foreach (var ca in customCAs) { _certificateAuthorities.TryAdd(ca.Id, ca); } } catch (Exception exp) { // failed to load custom CAs _serviceLog.Error(exp.Message); } // init remaining utilities and optionally enable telematics _challengeDiagnostics = new ChallengeDiagnostics(CoreAppSettings.Current.EnableValidationProxyAPI); if (CoreAppSettings.Current.EnableAppTelematics) { _tc = new Util().InitTelemetry(); } _httpChallengePort = serverConfig.HttpChallengeServerPort; _httpChallengeServerClient.Timeout = new TimeSpan(0, 0, 20); if (_tc != null) { _tc.TrackEvent("ServiceStarted"); } _serviceLog?.Information("Certify Manager Started"); PerformAccountUpgrades().Wait(); PerformManagedCertificateMigrations().Wait(); }
public CertifyManager(bool useWindowsNativeFeatures = true) { _useWindowsNativeFeatures = useWindowsNativeFeatures; var serverConfig = SharedUtils.ServiceConfigManager.GetAppServiceConfig(); SettingsManager.LoadAppSettings(); InitLogging(serverConfig); Util.SetSupportedTLSVersions(); try { _itemManager = new ItemManager(); } catch (Exception exp) { _serviceLog.Error($"Failed to open or upgrade the managed items database. Check service has required file access permissions. :: {exp}"); } _credentialsManager = new CredentialsManager(useWindowsNativeFeatures); _serverProvider = (ICertifiedServer) new ServerProviderIIS(); _progressResults = new ObservableCollection <RequestProgressState>(); _pluginManager = new PluginManager(); _pluginManager.EnableExternalPlugins = CoreAppSettings.Current.IncludeExternalPlugins; _pluginManager.LoadPlugins(new List <string> { "Licensing", "DashboardClient", "DeploymentTasks", "CertificateManagers", "DnsProviders" }); _migrationManager = new MigrationManager(_itemManager, _credentialsManager, _serverProvider); // load core CAs and custom CAs foreach (var ca in CertificateAuthority.CoreCertificateAuthorities) { _certificateAuthorities.TryAdd(ca.Id, ca); } try { var customCAs = SettingsManager.GetCustomCertificateAuthorities(); foreach (var ca in customCAs) { _certificateAuthorities.TryAdd(ca.Id, ca); } } catch (Exception exp) { // failed to load custom CAs _serviceLog.Error(exp.Message); } // init remaining utilities and optionally enable telematics _challengeDiagnostics = new ChallengeDiagnostics(CoreAppSettings.Current.EnableValidationProxyAPI); if (CoreAppSettings.Current.EnableAppTelematics) { _tc = new Util().InitTelemetry(); } _httpChallengePort = serverConfig.HttpChallengeServerPort; _httpChallengeServerClient.Timeout = new TimeSpan(0, 0, 20); if (_tc != null) { _tc.TrackEvent("ServiceStarted"); } _serviceLog?.Information("Certify Manager Started"); try { PerformAccountUpgrades().Wait(); } catch (Exception exp) { _serviceLog.Error($"Failed to perform ACME account upgrades. :: {exp}"); } PerformManagedCertificateMigrations().Wait(); }