Merge pull request #2767 from castrapel/expose_verisign_exception

Expose verisign exceptions
This commit is contained in:
Curtis 2019-04-25 19:28:44 -07:00 committed by GitHub
commit b300a21948
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 2 deletions

View File

@ -14,7 +14,7 @@ from cryptography import x509
from flask import current_app from flask import current_app
from lemur.common.utils import get_psuedo_random_string from lemur.common.utils import get_psuedo_random_string
from lemur.extensions import metrics from lemur.extensions import metrics, sentry
from lemur.plugins import lemur_verisign as verisign from lemur.plugins import lemur_verisign as verisign
from lemur.plugins.bases import IssuerPlugin, SourcePlugin from lemur.plugins.bases import IssuerPlugin, SourcePlugin
@ -201,7 +201,13 @@ class VerisignIssuerPlugin(IssuerPlugin):
current_app.logger.info("Requesting a new verisign certificate: {0}".format(data)) current_app.logger.info("Requesting a new verisign certificate: {0}".format(data))
response = self.session.post(url, data=data) response = self.session.post(url, data=data)
cert = handle_response(response.content)['Response']['Certificate'] try:
cert = handle_response(response.content)['Response']['Certificate']
except KeyError:
metrics.send('verisign_create_certificate_error', 'counter', 1,
metric_tags={"common_name": issuer_options.get("common_name", "")})
sentry.captureException(extra={"common_name": issuer_options.get("common_name", "")})
raise Exception(f"Error with Verisign: {response.content}")
# TODO add external id # TODO add external id
return cert, current_app.config.get('VERISIGN_INTERMEDIATE'), None return cert, current_app.config.get('VERISIGN_INTERMEDIATE'), None