]> WPIA git - gigi.git/blobdiff - tests/org/cacert/gigi/testUtils/PemKey.java
Shitty incompatible priv-key boundaries.
[gigi.git] / tests / org / cacert / gigi / testUtils / PemKey.java
index 9f5a27c00a96ce0077fb8f8a2c7c5ad2beb81e66..14d282fdce4e60c6566dea16a6ee908223589900 100644 (file)
@@ -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);