Source syncing tweaks. (#705)

* Allow owner to be specified when syncing certs.

* Ensuring non-endpoint plugins don't fail to complete syncing.

* Adding in some additional error handling.
This commit is contained in:
kevgliss 2017-03-03 14:53:56 -08:00 committed by GitHub
parent d53f64890c
commit fc957b63ff
4 changed files with 8 additions and 5 deletions

View File

@ -205,7 +205,7 @@ class CertificateUploadInputSchema(CertificateCreationSchema):
private_key = fields.String(validate=validators.private_key) private_key = fields.String(validate=validators.private_key)
body = fields.String(required=True, validate=validators.public_certificate) body = fields.String(required=True, validate=validators.public_certificate)
chain = fields.String(validate=validators.public_certificate, missing=None) # TODO this could be multiple certificates chain = fields.String(validate=validators.public_certificate, missing=None, allow_none=True) # TODO this could be multiple certificates
destinations = fields.Nested(AssociatedDestinationSchema, missing=[], many=True) destinations = fields.Nested(AssociatedDestinationSchema, missing=[], many=True)
notifications = fields.Nested(AssociatedNotificationSchema, missing=[], many=True) notifications = fields.Nested(AssociatedNotificationSchema, missing=[], many=True)

View File

@ -147,7 +147,7 @@ def domains(cert):
for entry in entries: for entry in entries:
domains.append(entry) domains.append(entry)
except Exception as e: except Exception as e:
current_app.logger.warning("Failed to get SubjectAltName: {0}".format(e)) pass
return domains return domains

View File

@ -20,7 +20,8 @@ def public_certificate(body):
""" """
try: try:
parse_certificate(body) parse_certificate(body)
except Exception: except Exception as e:
current_app.logger.exception(e)
raise ValidationError('Public certificate presented is not valid.') raise ValidationError('Public certificate presented is not valid.')

View File

@ -67,7 +67,7 @@ def sync_endpoints(source):
endpoints = s.get_endpoints(source.options) endpoints = s.get_endpoints(source.options)
except NotImplementedError: except NotImplementedError:
current_app.logger.warning("Unable to sync endpoints for source {0} plugin has not implemented 'get_endpoints'".format(source.label)) current_app.logger.warning("Unable to sync endpoints for source {0} plugin has not implemented 'get_endpoints'".format(source.label))
return return new, updated
for endpoint in endpoints: for endpoint in endpoints:
exists = endpoint_service.get_by_dnsname(endpoint['dnsname']) exists = endpoint_service.get_by_dnsname(endpoint['dnsname'])
@ -114,7 +114,9 @@ def sync_certificates(source, user):
for certificate in certificates: for certificate in certificates:
exists = certificate_service.get_by_name(certificate['name']) exists = certificate_service.get_by_name(certificate['name'])
if not certificate.get('owner'):
certificate['owner'] = user.email certificate['owner'] = user.email
certificate['creator'] = user certificate['creator'] = user
if not exists: if not exists: