tools: Strengthen BEGIN/END CERTIFICATE checks

insertkeys.py used beginswith() when checking that the BEGIN
and END CERTIFICATE clauses in PEM files were correct. It should
have done an explicit check on equality.

Change-Id: I5efb48d180bc674e6281a26a955acd248588b8bd
This commit is contained in:
William Roberts 2013-10-14 15:51:48 -07:00
parent 070c01f8f1
commit 14138335bd

View file

@ -40,7 +40,7 @@ class GenerateKeys(object):
for line in pkFile:
line = line.strip()
# Are we starting the certificate?
if line.startswith("-----BEGIN CERTIFICATE-----"):
if line == "-----BEGIN CERTIFICATE-----":
if inCert:
sys.exit("Encountered another BEGIN CERTIFICATE without END CERTIFICATE on " +
"line: " + str(lineNo))
@ -48,7 +48,7 @@ class GenerateKeys(object):
inCert = True
# Are we ending the ceritifcate?
elif line.startswith("-----END CERTIFICATE-----"):
elif line == "-----END CERTIFICATE-----":
if not inCert:
sys.exit("Encountered END CERTIFICATE before BEGIN CERTIFICATE on line: "
+ str(lineNo))