Skip to content

Commit

Permalink
Fix handling of non-existing ACME accounts with Digicert ACME endpoint (
Browse files Browse the repository at this point in the history
#681)

* Compatibility for DigiCert CA: also accept 404 instead of 400 for non-existing accounts.

* Add changelog fragment.

* Fix URL.
  • Loading branch information
felixfontein authored Dec 7, 2023
1 parent d9362a2 commit 67f1d11
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions changelogs/fragments/681-acme-account.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
bugfixes:
- "acme_* modules - make account registration handling more flexible to accept 404 instead of
400 send by DigiCert's ACME endpoint when an account does not exist (https://github.com/ansible-collections/community.crypto/pull/681)."
4 changes: 3 additions & 1 deletion plugins/module_utils/acme/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,10 @@ def _new_reg(self, contact=None, agreement=None, terms_agreed=False, allow_creat
if 'location' in info:
self.client.set_account_uri(info['location'])
return False, result
elif info['status'] == 400 and result['type'] == 'urn:ietf:params:acme:error:accountDoesNotExist' and not allow_creation:
elif info['status'] in (400, 404) and result['type'] == 'urn:ietf:params:acme:error:accountDoesNotExist' and not allow_creation:
# Account does not exist (and we did not try to create it)
# (According to RFC 8555, Section 7.3.1, the HTTP status code MUST be 400.
# Unfortunately Digicert does not care and sends 404 instead.)
return False, None
elif info['status'] == 403 and result['type'] == 'urn:ietf:params:acme:error:unauthorized' and 'deactivated' in (result.get('detail') or ''):
# Account has been deactivated; currently works for Pebble; has not been
Expand Down

0 comments on commit 67f1d11

Please sign in to comment.