Ensuring that destinations require private keys by default. (#390)

* Ensuring that destinations require private keys by default.
This commit is contained in:
kevgliss
2016-07-04 15:30:20 -07:00
committed by GitHub
parent 4ee1c21144
commit 4077893d08
9 changed files with 35 additions and 24 deletions

View File

@ -11,6 +11,7 @@ from lemur.plugins.base import Plugin
class DestinationPlugin(Plugin):
type = 'destination'
requires_key = True
def upload(self):
raise NotImplemented

View File

@ -68,19 +68,16 @@ class AWSDestinationPlugin(DestinationPlugin):
# }
def upload(self, name, body, private_key, cert_chain, options, **kwargs):
if private_key:
try:
iam.upload_cert(self.get_option('accountNumber', options), name, body, private_key,
cert_chain=cert_chain)
except BotoServerError as e:
if e.error_code != 'EntityAlreadyExists':
raise Exception(e)
try:
iam.upload_cert(self.get_option('accountNumber', options), name, body, private_key,
cert_chain=cert_chain)
except BotoServerError as e:
if e.error_code != 'EntityAlreadyExists':
raise Exception(e)
e = self.get_option('elb', options)
if e:
attach_certificate(kwargs['accountNumber'], ['region'], e['name'], e['port'], e['certificateId'])
else:
raise Exception("Unable to upload to AWS, private key is required")
e = self.get_option('elb', options)
if e:
attach_certificate(kwargs['accountNumber'], ['region'], e['name'], e['port'], e['certificateId'])
class AWSSourcePlugin(SourcePlugin):

View File

@ -236,9 +236,6 @@ class JavaKeystoreExportPlugin(ExportPlugin):
alias = "blah"
with mktemppath() as jks_tmp:
if not key:
raise Exception("Unable to export, no private key found.")
create_keystore(body, chain, jks_tmp, key, alias, passphrase)
with open(jks_tmp, 'rb') as f: