Revert the revert. (its time to sign MR1)
Revert "Waiting till post MR0 - this impacts signing tools for MR0."
This reverts commit a7b5c4a7dc77a0896d6314828b9ce85f82d103e8.
Bug: 11334314
Change-Id: I89f8996161e4258b80bf2d0bc7817f0e8e32df13
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index 58582ba..a3217dd 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -954,3 +954,18 @@
return PARTITION_TYPES[fstab[mount_point].fs_type], fstab[mount_point].device
else:
return None
+
+
+def ParseCertificate(data):
+ """Parse a PEM-format certificate."""
+ cert = []
+ save = False
+ for line in data.split("\n"):
+ if "--END CERTIFICATE--" in line:
+ break
+ if save:
+ cert.append(line)
+ if "--BEGIN CERTIFICATE--" in line:
+ save = True
+ cert = "".join(cert).decode('base64')
+ return cert