properly validate cert data that happens to contain an END substring

This commit is contained in:
Ryan Petrello
2018-11-06 15:57:35 -05:00
parent 8faa5d8b7a
commit 28cd762dd7
2 changed files with 26 additions and 2 deletions

View File

@@ -168,9 +168,9 @@ def validate_certificate(data):
Validate that data contains one or more certificates. Adds BEGIN/END lines
if necessary.
"""
if 'BEGIN' not in data:
if 'BEGIN ' not in data:
data = "-----BEGIN CERTIFICATE-----\n{}".format(data)
if 'END' not in data:
if 'END ' not in data:
data = "{}\n-----END CERTIFICATE-----\n".format(data)
return validate_pem(data, max_keys=0, min_certs=1)