Skip to content

Commit

Permalink
Fixes for PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Lane committed Feb 12, 2020
1 parent 5043fb9 commit c884cae
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion confidant/services/certificatemanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def get_csr_san(self, csr):
x509.SubjectAlternativeName
)
except ExtensionNotFound:
san = []
san = None
if san:
for dns_name in san.value:
dns_names.append(dns_name.value)
Expand Down Expand Up @@ -297,16 +297,21 @@ def _get_cached_certificate_with_key(self, cache_id):
return {}
# A certificate hasn't been issued yet, but since the cache id exists,
# another thread has requested the certificate.
i = 0
if not item.response:
# Wait for response
while True:
# Only allow a maximum of 10s wait.
# keep waiting while the lock is held.
if item.lock:
if i >= 100:
break
logging.debug(
'Sleeping in _get_cached_certificate_with_key'
' for {}'.format(cache_id)
)
time.sleep(.100)
i = i + 1
else:
break
# If the other thread failed to get the certificate, we need to ensure
Expand Down Expand Up @@ -357,6 +362,7 @@ def get_certificate_from_arn(self, certificate_arn):
# When a certificate is issued, it may take a while before it's
# available via get_certificate. We need to keep retrying until it's
# fully issued.
i = 0
while True:
try:
response = client.get_certificate(
Expand All @@ -365,12 +371,16 @@ def get_certificate_from_arn(self, certificate_arn):
)
break
except client.exceptions.RequestInProgressException:
# Sleep for a maximum of 10 seconds
if i >= 50:
raise
logging.debug(
'Sleeping in get_certificate_from_arn for {}'.format(
certificate_arn,
)
)
time.sleep(.200)
i = i + 1
return {
'certificate': response['Certificate'],
'certificate_chain': response['CertificateChain'],
Expand Down

0 comments on commit c884cae

Please sign in to comment.