Exemplo n.º 1
0
        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
            {
                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
                {
                    Type = x.Type,
                    Status = x.Status,
                    Uri = x.Uri,
                    Token = x.Token,
                    Tls = x.Tls,
                    ValidationRecord = x.ValidationRecord,
                }),
            };

            return authzState;
        }
Exemplo n.º 2
0
        public AuthorizationState AuthorizeIdentifier(string dnsIdentifier)
        {
            AssertInit();
            AssertRegistration();

            var requMsg = new NewAuthzRequest
            {
                Identifier = new IdentifierPart
                {
                    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 respMsg = JsonConvert.DeserializeObject<NewAuthzResponse>(resp.ContentAsString);

            var authzState = new AuthorizationState
            {
                Identifier = respMsg.Identifier.Value,
                Status = respMsg.Status,
                Combinations = respMsg.Combinations,

                // Simple copy/conversion from one form to another
                Challenges = respMsg.Challenges.Select(x => new AuthorizeChallenge
                {
                    Type = x.Type,
                    Status = x.Status,
                    Uri = x.Uri,
                    Token = x.Token,
                    Tls = x.Tls,
                }),
            };

            return authzState;
        }