public AuthorizationState AuthorizeIdentifier(string dnsIdentifier)
{
AssertInit();
AssertRegistration();
var requMsg = new NewAuthzRequest
{
Identifier = new IdentifierPart
{
Type = AcmeProtocol.IDENTIFIER_TYPE_DNS,
Value = dnsIdentifier
}
};
var resp = RequestHttpPost(new Uri(RootUrl,
Directory[AcmeServerDirectory.RES_NEW_AUTHZ]), requMsg);
if (resp.IsError)
{
throw new AcmeWebException(resp.Error as WebException,
"Unexpected error", resp);
}
var uri = resp.Headers[AcmeProtocol.HEADER_LOCATION];
if (string.IsNullOrEmpty(uri))
throw new AcmeProtocolException("Response is missing an identifier authorization resource URI", resp);
var respMsg = JsonConvert.DeserializeObject<NewAuthzResponse>(resp.ContentAsString);
var authzState = new AuthorizationState
{
IdentifierPart = respMsg.Identifier,
IdentifierType = respMsg.Identifier.Type,
Identifier = respMsg.Identifier.Value,
Uri = uri,
Status = respMsg.Status,
Expires = respMsg.Expires,
Combinations = respMsg.Combinations,
// Simple copy/conversion from one form to another
Challenges = respMsg.Challenges.Select(x => new AuthorizeChallenge
{
ChallengePart = x,
Type = x.Type,
Status = x.Status,
Uri = x.Uri,
Token = x.Token,
}),
};
return authzState;
}