From 26adba2db53b0a4cb7e965219e51175845407be2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Felix=20D=C3=B6rre?= Date: Wed, 23 Jul 2014 04:11:43 +0200 Subject: [PATCH] Shitty incompatible priv-key boundaries. e.g. mac openssl produces (-----BEGIN RSA PRIVATE KEY-----) --- tests/org/cacert/gigi/testUtils/PemKey.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/org/cacert/gigi/testUtils/PemKey.java b/tests/org/cacert/gigi/testUtils/PemKey.java index 9f5a27c0..14d282fd 100644 --- a/tests/org/cacert/gigi/testUtils/PemKey.java +++ b/tests/org/cacert/gigi/testUtils/PemKey.java @@ -10,9 +10,9 @@ import java.util.Base64; public class PemKey { public static PrivateKey parsePEMPrivateKey(String privKeyPEM) throws NoSuchAlgorithmException, InvalidKeySpecException { - privKeyPEM = privKeyPEM.replace("-----BEGIN PRIVATE KEY-----", "").replace("\n", ""); + privKeyPEM = privKeyPEM.replaceAll("-----BEGIN (RSA )?PRIVATE KEY-----", "").replace("\n", ""); // Remove the first and last lines - privKeyPEM = privKeyPEM.replace("-----END PRIVATE KEY-----", ""); + privKeyPEM = privKeyPEM.replaceAll("-----END (RSA )?PRIVATE KEY-----", ""); // Base64 decode the data byte[] encoded = Base64.getDecoder().decode(privKeyPEM); -- 2.39.2