internal void ChangeContacts() { var contacts = GetContacts(); var account = Retry(() => _client.UpdateAccountAsync(contacts, _client.Account).Result); UpdateAccount(); }
private async void refreshAccountButton_Click(object sender, EventArgs e) { var url = ResolveCaServerEndpoint(); if (url == null) { return; } await InvokeWithWaitCursor(async() => { var signer = new PkiJwsTool(256); signer.Import(_account.JwsSigner); using (var acme = new AcmeProtocolClient(url, signer: signer, acct: _account.Details)) { var dir = await acme.GetDirectoryAsync(); acme.Directory = dir; await acme.GetNonceAsync(); var details = await acme.UpdateAccountAsync(); _account.Details = details; Repo.SaveAccount(_account); } RebindAccountControls(); SetStatus("Account refreshed and saved"); }); }
internal async Task ChangeContacts() { var contacts = await GetContacts(); var account = await Retry(() => _client.UpdateAccountAsync(contacts, _client.Account)); await UpdateAccount(); }
public async Task <AcmeProtocolClient> CreateClientAsync() { var account = LoadState <AccountDetails>("account.json"); var accountKey = LoadState <AccountKey>("account_key.json"); var directory = LoadState <ServiceDirectory>("directory.json"); var acmeProtocolClient = new AcmeProtocolClient(_baseUri, directory, account, accountKey?.GenerateSigner(), usePostAsGet: true); if (directory == null) { try { directory = await acmeProtocolClient.GetDirectoryAsync(); } catch (AcmeProtocolException) { acmeProtocolClient.Directory.Directory = ""; directory = await acmeProtocolClient.GetDirectoryAsync(); } SaveState(directory, "directory.json"); acmeProtocolClient.Directory = directory; } await acmeProtocolClient.GetNonceAsync(); if (acmeProtocolClient.Account == null) { var externalAccountBinding = directory.Meta.ExternalAccountRequired ?? false?CreateExternalAccountBinding(acmeProtocolClient) : null; account = await acmeProtocolClient.CreateAccountAsync(new[] { $"mailto:{_options.Contacts}" }, true, externalAccountBinding); accountKey = new AccountKey { KeyType = acmeProtocolClient.Signer.JwsAlg, KeyExport = acmeProtocolClient.Signer.Export() }; SaveState(account, "account.json"); SaveState(accountKey, "account_key.json"); acmeProtocolClient.Account = account; } if (acmeProtocolClient.Account.Payload.Contact[0] != $"mailto:{_options.Contacts}") { account = await acmeProtocolClient.UpdateAccountAsync(new[] { $"mailto:{_options.Contacts}" }); SaveState(account, "account.json"); acmeProtocolClient.Account = account; } return(acmeProtocolClient); }
public async Task <bool> UpdateAccount(ILog log, string email, bool termsAgreed) { try { _ = await _client.UpdateAccountAsync(new[] { email }); return(true); } catch (Exception exp) { log.Error(exp.Message); return(false); } }