summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
3fb5d9f)
e.g. mac openssl produces (-----BEGIN RSA PRIVATE KEY-----)
public class PemKey {
public static PrivateKey parsePEMPrivateKey(String privKeyPEM) throws NoSuchAlgorithmException,
InvalidKeySpecException {
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
// 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);
// Base64 decode the data
byte[] encoded = Base64.getDecoder().decode(privKeyPEM);