mirror of
https://github.com/certbot/certbot.git
synced 2026-07-30 16:14:44 +02:00
+32
-5
@@ -25,6 +25,14 @@ class Challenge(jose.TypedJSONObjectWithFields):
|
|||||||
"""ACME challenge."""
|
"""ACME challenge."""
|
||||||
TYPES = {}
|
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
|
class ContinuityChallenge(Challenge): # pylint: disable=abstract-method
|
||||||
"""Client validation challenges."""
|
"""Client validation challenges."""
|
||||||
@@ -34,11 +42,6 @@ class DVChallenge(Challenge): # pylint: disable=abstract-method
|
|||||||
"""Domain validation challenges."""
|
"""Domain validation challenges."""
|
||||||
|
|
||||||
|
|
||||||
class UnrecognizedChallenge(Challenge):
|
|
||||||
"""Unrecognized challenge."""
|
|
||||||
typ = "unknown"
|
|
||||||
|
|
||||||
|
|
||||||
class ChallengeResponse(jose.TypedJSONObjectWithFields):
|
class ChallengeResponse(jose.TypedJSONObjectWithFields):
|
||||||
# _fields_to_partial_json | pylint: disable=abstract-method
|
# _fields_to_partial_json | pylint: disable=abstract-method
|
||||||
"""ACME challenge response."""
|
"""ACME challenge response."""
|
||||||
@@ -47,6 +50,30 @@ class ChallengeResponse(jose.TypedJSONObjectWithFields):
|
|||||||
resource = fields.Resource(resource_type)
|
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
|
@Challenge.register
|
||||||
class SimpleHTTP(DVChallenge):
|
class SimpleHTTP(DVChallenge):
|
||||||
"""ACME "simpleHttp" challenge.
|
"""ACME "simpleHttp" challenge.
|
||||||
|
|||||||
+1
-13
@@ -373,19 +373,7 @@ class Authorization(ResourceBody):
|
|||||||
|
|
||||||
@challenges.decoder
|
@challenges.decoder
|
||||||
def challenges(value): # pylint: disable=missing-docstring,no-self-argument
|
def challenges(value): # pylint: disable=missing-docstring,no-self-argument
|
||||||
# The from_json method raises errors.UnrecognizedTypeError when a
|
return tuple(ChallengeBody.from_json(chall) for chall in value)
|
||||||
# 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)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def resolved_combinations(self):
|
def resolved_combinations(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user