/// <summary> /// Account create with external account binding. /// </summary> /// <see cref="https://tools.ietf.org/html/draft-ietf-acme-acme-12#section-7.3.5"/> public async Task <AcmeResponse <Protocol.Account> > AccountCreateAsync(Protocol.Messages.NewAccount account, string kid, string keyMac) { Logger.Info("Creating a new ACME account with external account binding. Params:{@params}", new { Account = account, KeyId = kid, KeyMac = keyMac, }); var jws = new JsonWebSignature(); jws.SetProtected(new JsonWebSignatureProtected { Algorithm = AlgorithmsEnum.HS256, KeyID = kid, Url = Directory.NewAccount, }); jws.SetPayload(new JsonWebKey(Key)); var key = HMAC.Create("HMACSHA256"); key.Key = Base64Url.Decode(keyMac); jws.Sign(key); account.ExternalAccountBinding = jws; return(await AccountCreateAsync(account)); }
/// <summary> /// Updates existing Account information registered with the ACME CA. /// </summary> /// <see cref="https://tools.ietf.org/html/draft-ietf-acme-acme-12#section-7.3.2"/> /// <see cref="https://tools.ietf.org/html/draft-ietf-acme-acme-12#section-7.3.3"/> /// <see cref="https://tools.ietf.org/html/draft-ietf-acme-acme-12#section-7.3.4"/> public async Task <AcmeResponse <Protocol.Account> > AccountUpdateAsync(Protocol.Messages.NewAccount account) { Logger.Info("Updating an ACME account. Params:{@params}", account); var response = await Request(GetType(typeof(Protocol.Account)), Directory.NewAccount, new RequestParams { Method = HttpMethod.Post, Payload = account }); if (string.IsNullOrEmpty(response.Headers.Location)) { var ex = new AcmeException(Protocol.ErrorType.IncorrectResponse, "Account updating response does not include Location header."); Logger.Error(ex, $"{nameof(AcmeClient)} request error."); throw ex; } Location = response.Headers.Location; return(response); }