private async Task <IAcmeContext> GetContext() { if (_acme != null) { return(_acme); } var existingAccountKey = await _persistenceService.GetPersistedAccountCertificateAsync(); if (existingAccountKey != null) { _logger.LogDebug("Using existing LetsEncrypt account."); var acme = new AcmeContext(_options.LetsEncryptUri, existingAccountKey); await acme.Account(); return(_acme = acme); } else { _logger.LogDebug("Creating LetsEncrypt account with email {0}.", _options.Email); var acme = new AcmeContext(_options.LetsEncryptUri); await acme.NewAccount(_options.Email, true); await _persistenceService.PersistAccountCertificateAsync(acme.AccountKey); return(_acme = acme); } }
private async Task AuthenticateAsync() { if (acme != null) { return; } var existingAccountKey = await _persistenceService.GetPersistedAccountCertificateAsync(); if (existingAccountKey != null) { await UseExistingLetsEncryptAccount(existingAccountKey); } else { await CreateNewLetsEncryptAccount(); } }