mirror of
https://github.com/certbot/certbot.git
synced 2026-01-23 07:20:55 +03:00
Fix #521 by introducing MissingNonceError, which by shows response headers when printed to STDOUT. More sensible solution (a'la #523) is blocked by boulder#417 (HTTP 405 response for HEAD). Split out ClientNetworkWithMockedResponseTest from ClientNetworkTest, which improves readability and makes it easier to test (less mocks).
54 lines
1.4 KiB
Python
54 lines
1.4 KiB
Python
"""ACME errors."""
|
|
from acme.jose import errors as jose_errors
|
|
|
|
|
|
class Error(Exception):
|
|
"""Generic ACME error."""
|
|
|
|
|
|
class SchemaValidationError(jose_errors.DeserializationError):
|
|
"""JSON schema ACME object validation error."""
|
|
|
|
|
|
class ClientError(Error):
|
|
"""Network error."""
|
|
|
|
|
|
class UnexpectedUpdate(ClientError):
|
|
"""Unexpected update error."""
|
|
|
|
|
|
class NonceError(ClientError):
|
|
"""Server response nonce error."""
|
|
|
|
|
|
class BadNonce(NonceError):
|
|
"""Bad nonce error."""
|
|
def __init__(self, nonce, error, *args, **kwargs):
|
|
super(BadNonce, self).__init__(*args, **kwargs)
|
|
self.nonce = nonce
|
|
self.error = error
|
|
|
|
def __str__(self):
|
|
return 'Invalid nonce ({0!r}): {1}'.format(self.nonce, self.error)
|
|
|
|
|
|
class MissingNonce(NonceError):
|
|
"""Missing nonce error.
|
|
|
|
According to the specification an "ACME server MUST include an
|
|
Replay-Nonce header field in each successful response to a POST it
|
|
provides to a client (...)".
|
|
|
|
:ivar requests.Response response: HTTP Response
|
|
|
|
"""
|
|
def __init__(self, response, *args, **kwargs):
|
|
super(MissingNonce, self).__init__(*args, **kwargs)
|
|
self.response = response
|
|
|
|
def __str__(self):
|
|
return ('Server {0} response did not include a replay '
|
|
'nonce, headers: {1}'.format(
|
|
self.response.request.method, self.response.headers))
|