public AcmeRegistration UpdateRegistration(bool useRootUrl = false, bool agreeToTos = false, string[] contacts = null)
{
AssertInit();
AssertRegistration();
var requMsg = new UpdateRegRequest();
if (contacts != null)
requMsg.Contact = contacts;
if (agreeToTos && !string.IsNullOrWhiteSpace(Registration.TosLinkUri))
requMsg.Agreement = Registration.TosLinkUri;
// Compute the URL to submit the request to, either exactly as
// provided in the Registration object or relative to the Root URL
var requUri = new Uri(Registration.RegistrationUri);
if (useRootUrl)
requUri = new Uri(RootUrl, requUri.PathAndQuery);
var resp = RequestHttpPost(requUri, requMsg);
if (resp.IsError)
{
throw new AcmeWebException(resp.Error as WebException,
"Unexpected error", resp);
}
var respMsg = JsonConvert.DeserializeObject<RegResponse>(resp.ContentAsString);
var updReg = new AcmeRegistration
{
PublicKey = Signer.ExportJwk(),
RegistrationUri = Registration.RegistrationUri,
Contacts = respMsg.Contact,
Links = resp.Links,
/// Extracts the "Terms of Service" related link header if there is one and
/// returns the URI associated with it. Otherwise returns <c>null</c>.
TosLinkUri = resp.Links[AcmeProtocol.LINK_HEADER_REL_TOS].FirstOrDefault(),
AuthorizationsUri = respMsg.Authorizations,
CertificatesUri = respMsg.Certificates,
TosAgreementUri = respMsg.Agreement,
};
Registration = updReg;
return Registration;
}