Skip to content

Commit

Permalink
fixes #2244
Browse files Browse the repository at this point in the history
  • Loading branch information
Frederic BLANC authored and bmw committed Jan 25, 2017
1 parent 578815a commit b6fecca
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions acme/acme/client.py
Expand Up @@ -676,8 +676,16 @@ def _get_nonce(self, url):

def post(self, url, obj, content_type=JOSE_CONTENT_TYPE, **kwargs):
"""POST object wrapped in `.JWS` and check response."""
data = self._wrap_in_jws(obj, self._get_nonce(url))
kwargs.setdefault('headers', {'Content-Type': content_type})
response = self._send_request('POST', url, data=data, **kwargs)
self._add_nonce(response)
return self._check_response(response, content_type=content_type)
MAX_ATTEMPTS = 3
for attempt in range(MAX_ATTEMPTS+1):
try:
data = self._wrap_in_jws(obj, self._get_nonce(url))
kwargs.setdefault('headers', {'Content-Type': content_type})
response = self._send_request('POST', url, data=data, **kwargs)
self._add_nonce(response)
return self._check_response(response, content_type=content_type)
except messages.Error as e:
if attempt < MAX_ATTEMPTS and e.typ == 'urn:ietf:params:acme:error:badNonce':
logger.debug('Got badNonce error (%i times)', attempt+1)
else:
raise

0 comments on commit b6fecca

Please sign in to comment.