Merge branch 'master' into master
This commit is contained in:
@ -32,6 +32,7 @@ from lemur.extensions import metrics, sentry
|
||||
from lemur.plugins import lemur_acme as acme
|
||||
from lemur.plugins.bases import IssuerPlugin
|
||||
from lemur.plugins.lemur_acme import cloudflare, dyn, route53, ultradns
|
||||
from retrying import retry
|
||||
|
||||
|
||||
class AuthorizationRecord(object):
|
||||
@ -197,6 +198,7 @@ class AcmeHandler(object):
|
||||
)
|
||||
return pem_certificate, pem_certificate_chain
|
||||
|
||||
@retry(stop_max_attempt_number=5, wait_fixed=5000)
|
||||
def setup_acme_client(self, authority):
|
||||
if not authority.options:
|
||||
raise InvalidAuthority("Invalid authority. Options not set")
|
||||
|
@ -10,7 +10,7 @@ import botocore
|
||||
|
||||
from retrying import retry
|
||||
|
||||
from lemur.extensions import metrics
|
||||
from lemur.extensions import metrics, sentry
|
||||
from lemur.plugins.lemur_aws.sts import sts_client
|
||||
|
||||
|
||||
@ -122,9 +122,11 @@ def get_certificate(name, **kwargs):
|
||||
"""
|
||||
client = kwargs.pop("client")
|
||||
metrics.send("get_certificate", "counter", 1, metric_tags={"name": name})
|
||||
return client.get_server_certificate(ServerCertificateName=name)[
|
||||
"ServerCertificate"
|
||||
]
|
||||
try:
|
||||
return client.get_server_certificate(ServerCertificateName=name)["ServerCertificate"]
|
||||
except client.exceptions.NoSuchEntityException:
|
||||
sentry.captureException()
|
||||
return None
|
||||
|
||||
|
||||
@sts_client("iam")
|
||||
|
@ -32,7 +32,9 @@
|
||||
.. moduleauthor:: Mikhail Khodorovskiy <mikhail.khodorovskiy@jivesoftware.com>
|
||||
.. moduleauthor:: Harm Weites <harm@weites.com>
|
||||
"""
|
||||
from acme.errors import ClientError
|
||||
from flask import current_app
|
||||
from lemur.extensions import sentry, metrics
|
||||
|
||||
from lemur.plugins import lemur_aws as aws
|
||||
from lemur.plugins.bases import DestinationPlugin, ExportDestinationPlugin, SourcePlugin
|
||||
@ -271,6 +273,29 @@ class AWSSourcePlugin(SourcePlugin):
|
||||
account_number = self.get_option("accountNumber", options)
|
||||
iam.delete_cert(certificate.name, account_number=account_number)
|
||||
|
||||
def get_certificate_by_name(self, certificate_name, options):
|
||||
account_number = self.get_option("accountNumber", options)
|
||||
# certificate name may contain path, in which case we remove it
|
||||
if "/" in certificate_name:
|
||||
certificate_name = certificate_name.split('/')[-1]
|
||||
try:
|
||||
cert = iam.get_certificate(certificate_name, account_number=account_number)
|
||||
if cert:
|
||||
return dict(
|
||||
body=cert["CertificateBody"],
|
||||
chain=cert.get("CertificateChain"),
|
||||
name=cert["ServerCertificateMetadata"]["ServerCertificateName"],
|
||||
)
|
||||
except ClientError:
|
||||
current_app.logger.warning(
|
||||
"get_elb_certificate_failed: Unable to get certificate for {0}".format(certificate_name))
|
||||
sentry.captureException()
|
||||
metrics.send(
|
||||
"get_elb_certificate_failed", "counter", 1,
|
||||
metric_tags={"certificate_name": certificate_name, "account_number": account_number}
|
||||
)
|
||||
return None
|
||||
|
||||
|
||||
class AWSDestinationPlugin(DestinationPlugin):
|
||||
title = "AWS"
|
||||
|
Reference in New Issue
Block a user