mirror of
https://github.com/certbot/certbot.git
synced 2026-08-04 12:32:02 +02:00
Remove POST-as-GET fallback to GET (#6994)
This commit is contained in:
committed by
ohemorange
parent
6d527bcc42
commit
887d72fd5d
+1
-17
@@ -776,29 +776,13 @@ class ClientV2(ClientBase):
|
|||||||
|
|
||||||
def _post_as_get(self, *args, **kwargs):
|
def _post_as_get(self, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
Send GET request using the POST-as-GET protocol if needed.
|
Send GET request using the POST-as-GET protocol.
|
||||||
The request will be first issued using POST-as-GET for ACME v2. If the ACME CA servers do
|
|
||||||
not support this yet and return an error, request will be retried using GET.
|
|
||||||
For ACME v1, only GET request will be tried, as POST-as-GET is not supported.
|
|
||||||
:param args:
|
:param args:
|
||||||
:param kwargs:
|
:param kwargs:
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
if self.acme_version >= 2:
|
|
||||||
# We add an empty payload for POST-as-GET requests
|
|
||||||
new_args = args[:1] + (None,) + args[1:]
|
new_args = args[:1] + (None,) + args[1:]
|
||||||
try:
|
|
||||||
return self._post(*new_args, **kwargs)
|
return self._post(*new_args, **kwargs)
|
||||||
except messages.Error as error:
|
|
||||||
if error.code == 'malformed':
|
|
||||||
logger.debug('Error during a POST-as-GET request, '
|
|
||||||
'your ACME CA server may not support it:\n%s', error)
|
|
||||||
logger.debug('Retrying request with GET.')
|
|
||||||
else: # pragma: no cover
|
|
||||||
raise
|
|
||||||
|
|
||||||
# If POST-as-GET is not supported yet, we use a GET instead.
|
|
||||||
return self.net.get(*args, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
class BackwardsCompatibleClientV2(object):
|
class BackwardsCompatibleClientV2(object):
|
||||||
|
|||||||
@@ -885,19 +885,6 @@ class ClientV2Test(ClientTestBase):
|
|||||||
new_nonce_url='https://www.letsencrypt-demo.org/acme/new-nonce')
|
new_nonce_url='https://www.letsencrypt-demo.org/acme/new-nonce')
|
||||||
self.client.net.get.assert_not_called()
|
self.client.net.get.assert_not_called()
|
||||||
|
|
||||||
class FakeError(messages.Error):
|
|
||||||
"""Fake error to reproduce a malformed request ACME error"""
|
|
||||||
def __init__(self): # pylint: disable=super-init-not-called
|
|
||||||
pass
|
|
||||||
@property
|
|
||||||
def code(self):
|
|
||||||
return 'malformed'
|
|
||||||
self.client.net.post.side_effect = FakeError()
|
|
||||||
|
|
||||||
self.client.poll(self.authzr2) # pylint: disable=protected-access
|
|
||||||
|
|
||||||
self.client.net.get.assert_called_once_with(self.authzr2.uri)
|
|
||||||
|
|
||||||
|
|
||||||
class MockJSONDeSerializable(jose.JSONDeSerializable):
|
class MockJSONDeSerializable(jose.JSONDeSerializable):
|
||||||
# pylint: disable=missing-docstring
|
# pylint: disable=missing-docstring
|
||||||
|
|||||||
Reference in New Issue
Block a user