diff --git a/tools/insertkeys.py b/tools/insertkeys.py
index 7237d6f9ec610859cd348b5ddd9cd24cb77f5f3d..ca1e4328032407b354a1e3163e35740fb89a84a3 100755
--- a/tools/insertkeys.py
+++ b/tools/insertkeys.py
@@ -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))