public void PerformUpgrades() { // check if there are no registered contacts, if so see if we are upgrading from a vault if (GetContactRegistrations().Count == 0) { var acmeVaultMigration = new Models.Compat.ACMEVaultUpgrader(); if (acmeVaultMigration.HasACMEVault()) { string email = acmeVaultMigration.GetContact(); if (!String.IsNullOrEmpty(email)) { var addedOK = _acmeClientProvider.AddNewAccountAndAcceptTOS(_serviceLog, email).Result; } } } }
public async Task PerformUpgrades() { // check if there are no registered contacts, if so see if we are upgrading from a vault if (GetContactRegistrations().Count == 0) { var acmeVaultMigration = new Models.Compat.ACMEVaultUpgrader(); if (acmeVaultMigration.HasACMEVault()) { var email = acmeVaultMigration.GetContact(); if (!string.IsNullOrEmpty(email)) { var addedOK = await _acmeClientProvider.AddNewAccountAndAcceptTOS(_serviceLog, email); _serviceLog?.Information("Account upgrade completed (vault)"); } } } }
private async Task PerformAccountUpgrades() { // check if there are no registered contacts, if so see if we are upgrading from a vault var accounts = await GetAccountRegistrations(); if (!accounts.Any()) { // if we have no accounts we need to check for required upgrades // contacts may be JSON or legacy vault // create provider pointing to legacy storage var apiEndpoint = _certificateAuthorities[StandardCertAuthorities.LETS_ENCRYPT].ProductionAPIEndpoint; var provider = new CertesACMEProvider(apiEndpoint, Management.Util.GetAppDataFolder() + "\\certes", Util.GetUserAgent()); await provider.InitProvider(_serviceLog); var acc = (provider as CertesACMEProvider).GetCurrentAcmeAccount(); if (acc != null) { // we have a legacy certes account to migrate to the newer account store var newId = Guid.NewGuid().ToString(); acc.ID = newId; acc.StorageKey = newId; acc.IsStagingAccount = false; acc.CertificateAuthorityId = StandardCertAuthorities.LETS_ENCRYPT; accounts.Add(acc); await StoreAccountAsCredential(acc); } if (accounts.Count() == 0) { // still no accounts, check for old vault upgrade var acmeVaultMigration = new Models.Compat.ACMEVaultUpgrader(); if (acmeVaultMigration.HasACMEVault()) { var email = acmeVaultMigration.GetContact(); if (!string.IsNullOrEmpty(email)) { var registerResult = await provider.AddNewAccountAndAcceptTOS(_serviceLog, email); if (registerResult.IsSuccess) { var newId = Guid.NewGuid().ToString(); acc = registerResult.Result; acc.ID = newId; acc.StorageKey = newId; acc.IsStagingAccount = false; acc.CertificateAuthorityId = StandardCertAuthorities.LETS_ENCRYPT; accounts.Add(acc); await StoreAccountAsCredential(acc); _serviceLog?.Information("Account upgrade completed (vault)"); } else { _serviceLog?.Information($"Account upgrade failed (vault):{registerResult?.Message}"); } } } } } }