mirror of
https://github.com/certbot/certbot.git
synced 2026-08-02 00:22:28 +02:00
Factor out _TokenDVChallenge.
This commit is contained in:
+16
-26
@@ -76,26 +76,21 @@ class UnrecognizedChallenge(Challenge):
|
|||||||
return cls(jobj)
|
return cls(jobj)
|
||||||
|
|
||||||
|
|
||||||
@Challenge.register
|
class _TokenDVChallenge(DVChallenge):
|
||||||
class SimpleHTTP(DVChallenge):
|
"""DV Challenge with token.
|
||||||
"""ACME "simpleHttp" challenge.
|
|
||||||
|
|
||||||
:ivar unicode token:
|
:ivar unicode token:
|
||||||
|
|
||||||
"""
|
"""
|
||||||
typ = "simpleHttp"
|
|
||||||
|
|
||||||
TOKEN_SIZE = 128 / 8 # Based on the entropy value from the spec
|
TOKEN_SIZE = 128 / 8 # Based on the entropy value from the spec
|
||||||
"""Minimum size of the :attr:`token` in bytes."""
|
"""Minimum size of the :attr:`token` in bytes."""
|
||||||
|
|
||||||
URI_ROOT_PATH = ".well-known/acme-challenge"
|
|
||||||
"""URI root path for the server provisioned resource."""
|
|
||||||
|
|
||||||
# TODO: acme-spec doesn't specify token as base64-encoded value
|
# TODO: acme-spec doesn't specify token as base64-encoded value
|
||||||
token = jose.Field(
|
token = jose.Field(
|
||||||
"token", encoder=jose.encode_b64jose, decoder=functools.partial(
|
"token", encoder=jose.encode_b64jose, decoder=functools.partial(
|
||||||
jose.decode_b64jose, size=TOKEN_SIZE, minimum=True))
|
jose.decode_b64jose, size=TOKEN_SIZE, minimum=True))
|
||||||
|
|
||||||
|
# XXX: rename to ~token_good_for_url
|
||||||
@property
|
@property
|
||||||
def good_token(self): # XXX: @token.decoder
|
def good_token(self): # XXX: @token.decoder
|
||||||
"""Is `token` good?
|
"""Is `token` good?
|
||||||
@@ -109,6 +104,15 @@ class SimpleHTTP(DVChallenge):
|
|||||||
# URI_ROOT_PATH!
|
# URI_ROOT_PATH!
|
||||||
return b'..' not in self.token and b'/' not in self.token
|
return b'..' not in self.token and b'/' not in self.token
|
||||||
|
|
||||||
|
|
||||||
|
@Challenge.register # pylint: disable=too-many-ancestors
|
||||||
|
class SimpleHTTP(_TokenDVChallenge):
|
||||||
|
"""ACME "simpleHttp" challenge."""
|
||||||
|
typ = "simpleHttp"
|
||||||
|
|
||||||
|
URI_ROOT_PATH = ".well-known/acme-challenge"
|
||||||
|
"""URI root path for the server provisioned resource."""
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def path(self):
|
def path(self):
|
||||||
"""Path (starting with '/') for provisioned resource."""
|
"""Path (starting with '/') for provisioned resource."""
|
||||||
@@ -274,8 +278,8 @@ class SimpleHTTPProvisionedResource(jose.JSONObjectWithFields):
|
|||||||
tls = jose.Field("tls", omitempty=False)
|
tls = jose.Field("tls", omitempty=False)
|
||||||
|
|
||||||
|
|
||||||
@Challenge.register
|
@Challenge.register # pylint: disable=too-many-ancestors
|
||||||
class DVSNI(DVChallenge):
|
class DVSNI(_TokenDVChallenge):
|
||||||
"""ACME "dvsni" challenge.
|
"""ACME "dvsni" challenge.
|
||||||
|
|
||||||
:ivar bytes token: Random data, **not** base64-encoded.
|
:ivar bytes token: Random data, **not** base64-encoded.
|
||||||
@@ -286,13 +290,6 @@ class DVSNI(DVChallenge):
|
|||||||
PORT = 443
|
PORT = 443
|
||||||
"""Port to perform DVSNI challenge."""
|
"""Port to perform DVSNI challenge."""
|
||||||
|
|
||||||
TOKEN_SIZE = 128 / 8 # Based on the entropy value from the spec
|
|
||||||
"""Minimum size of the :attr:`token` in bytes."""
|
|
||||||
|
|
||||||
token = jose.Field(
|
|
||||||
"token", encoder=jose.encode_b64jose, decoder=functools.partial(
|
|
||||||
jose.decode_b64jose, size=TOKEN_SIZE, minimum=True))
|
|
||||||
|
|
||||||
def gen_response(self, account_key, alg=jose.RS256, **kwargs):
|
def gen_response(self, account_key, alg=jose.RS256, **kwargs):
|
||||||
"""Generate response.
|
"""Generate response.
|
||||||
|
|
||||||
@@ -548,8 +545,8 @@ class ProofOfPossessionResponse(ChallengeResponse):
|
|||||||
return self.signature.verify(self.nonce)
|
return self.signature.verify(self.nonce)
|
||||||
|
|
||||||
|
|
||||||
@Challenge.register
|
@Challenge.register # pylint: disable=too-many-ancestors
|
||||||
class DNS(DVChallenge):
|
class DNS(_TokenDVChallenge):
|
||||||
"""ACME "dns" challenge.
|
"""ACME "dns" challenge.
|
||||||
|
|
||||||
:ivar unicode token:
|
:ivar unicode token:
|
||||||
@@ -560,13 +557,6 @@ class DNS(DVChallenge):
|
|||||||
LABEL = "_acme-challenge"
|
LABEL = "_acme-challenge"
|
||||||
"""Label clients prepend to the domain name being validated."""
|
"""Label clients prepend to the domain name being validated."""
|
||||||
|
|
||||||
TOKEN_SIZE = 128 / 8 # Based on the entropy value from the spec
|
|
||||||
"""Minimum size of the :attr:`token` in bytes."""
|
|
||||||
|
|
||||||
token = jose.Field(
|
|
||||||
"token", encoder=jose.encode_b64jose, decoder=functools.partial(
|
|
||||||
jose.decode_b64jose, size=TOKEN_SIZE, minimum=True))
|
|
||||||
|
|
||||||
def gen_validation(self, account_key, alg=jose.RS256, **kwargs):
|
def gen_validation(self, account_key, alg=jose.RS256, **kwargs):
|
||||||
"""Generate validation.
|
"""Generate validation.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user