mirror of
https://github.com/certbot/certbot.git
synced 2026-01-23 07:20:55 +03:00
@@ -25,6 +25,14 @@ class Challenge(jose.TypedJSONObjectWithFields):
|
||||
"""ACME challenge."""
|
||||
TYPES = {}
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, jobj):
|
||||
try:
|
||||
return super(Challenge, cls).from_json(jobj)
|
||||
except jose.UnrecognizedTypeError as error:
|
||||
logger.debug(error)
|
||||
return UnrecognizedChallenge.from_json(jobj)
|
||||
|
||||
|
||||
class ContinuityChallenge(Challenge): # pylint: disable=abstract-method
|
||||
"""Client validation challenges."""
|
||||
@@ -34,11 +42,6 @@ class DVChallenge(Challenge): # pylint: disable=abstract-method
|
||||
"""Domain validation challenges."""
|
||||
|
||||
|
||||
class UnrecognizedChallenge(Challenge):
|
||||
"""Unrecognized challenge."""
|
||||
typ = "unknown"
|
||||
|
||||
|
||||
class ChallengeResponse(jose.TypedJSONObjectWithFields):
|
||||
# _fields_to_partial_json | pylint: disable=abstract-method
|
||||
"""ACME challenge response."""
|
||||
@@ -47,6 +50,30 @@ class ChallengeResponse(jose.TypedJSONObjectWithFields):
|
||||
resource = fields.Resource(resource_type)
|
||||
|
||||
|
||||
class UnrecognizedChallenge(Challenge):
|
||||
"""Unrecognized challenge.
|
||||
|
||||
ACME specification defines a generic framework for challenges and
|
||||
defines some standard challenges that are implemented in this
|
||||
module. However, other implementations (including peers) might
|
||||
define additional challenge types, which should be ignored if
|
||||
unrecognized.
|
||||
|
||||
:ivar jobj: Original JSON decoded object.
|
||||
|
||||
"""
|
||||
|
||||
def __init__(self, jobj):
|
||||
object.__setattr__(self, "jobj", jobj)
|
||||
|
||||
def to_partial_json(self):
|
||||
return self.jobj
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, jobj):
|
||||
return cls(jobj)
|
||||
|
||||
|
||||
@Challenge.register
|
||||
class SimpleHTTP(DVChallenge):
|
||||
"""ACME "simpleHttp" challenge.
|
||||
|
||||
@@ -373,19 +373,7 @@ class Authorization(ResourceBody):
|
||||
|
||||
@challenges.decoder
|
||||
def challenges(value): # pylint: disable=missing-docstring,no-self-argument
|
||||
# The from_json method raises errors.UnrecognizedTypeError when a
|
||||
# challenge of unknown type is encountered. We want to ignore this
|
||||
# case. This forces us to do an explicit iteration, since list
|
||||
# comprehensions can't handle exceptions.
|
||||
challs = []
|
||||
for chall in value:
|
||||
try:
|
||||
challs.append(ChallengeBody.from_json(chall))
|
||||
except jose.UnrecognizedTypeError:
|
||||
challs.append(ChallengeBody(
|
||||
uri="UNKNOWN", chall=challenges.UnrecognizedChallenge,
|
||||
status=STATUS_UNKNOWN))
|
||||
return tuple(challs)
|
||||
return tuple(ChallengeBody.from_json(chall) for chall in value)
|
||||
|
||||
@property
|
||||
def resolved_combinations(self):
|
||||
|
||||
Reference in New Issue
Block a user