Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kshcherban committed Jul 28, 2018
1 parent 520d8e8 commit 2e50141
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions acme_nginx/Acme.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,15 +262,15 @@ def _verify_challenge(self, url, domain):
sys.exit(1)

@staticmethod
def _get_challenge(auth, challenge_type):
def _get_challenge(challenges, challenge_type):
"""
Return challenge from dict
Params:
auth, dict, auth data structure from acme api
challenge, dict, challenge data structure from acme api
challenge_type, str, challenge type
Return:
challenge key
"""
for c in auth['challenges']:
if c['type'] == challenge_type:
return c
for challenge in challenges:
if challenge['type'] == challenge_type:
return challenge
2 changes: 1 addition & 1 deletion acme_nginx/AcmeV1.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def get_certificate(self):
if code != 201:
self.log.error('error requesting challenges: {0} {1}'.format(code, result))
sys.exit(1)
challenge = self._get_challenge(json.loads(result), "http-01")
challenge = self._get_challenge(json.loads(result)['challenges'], "http-01")
token = re.sub(r"[^A-Za-z0-9_\-]", "_", challenge['token'])
thumbprint = self._thumbprint()
self.log.info('adding nginx virtual host and completing challenge')
Expand Down
4 changes: 2 additions & 2 deletions acme_nginx/AcmeV2.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def solve_http_challenge(self, directory):
self.log.debug(json.dumps(auth))
domain = auth['identifier']['value']
self.log.info('verifying domain {0}'.format(domain))
challenge = self._get_challenge(auth, "http-01")
challenge = self._get_challenge(auth['challenges'], "http-01")
token = re.sub(r"[^A-Za-z0-9_\-]", "_", challenge['token'])
thumbprint = self._thumbprint()
self.log.info('adding nginx virtual host and completing challenge')
Expand Down Expand Up @@ -142,7 +142,7 @@ def solve_dns_challenge(self, directory, client):
self.log.debug(json.dumps(auth))
domain = auth['identifier']['value']
self.log.info('verifying domain {0}'.format(domain))
challenge = self._get_challenge(auth, "dns-01")
challenge = self._get_challenge(auth['challenges'], "dns-01")
token = re.sub(r"[^A-Za-z0-9_\-]", "_", challenge['token'])
thumbprint = self._thumbprint()
keyauthorization = "{0}.{1}".format(token, thumbprint)
Expand Down

0 comments on commit 2e50141

Please sign in to comment.