I have a String variable that contains a test Private key, when outputting the key string, it looks like this:
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,BD15DCECA635FDE0
[Encrypted-Key-Contents]
-----END RSA PRIVATE KEY-----
I've checked on my ubuntu system and the key is valid and working. However, when I try to run PEMParser on it, it just hangs and I get no exception thrown. Here is what I do in order to parse it:
System.out.println(myKey); // this outputs the key just fine.
Security.addProvider(new BouncyCastleProvider());
InputStream keyInput = new ByteArrayInputStream(myKey.getBytes());
InputStreamReader in2 = new InputStreamReader(keyInput);
PEMParser parserPrivateKey = new PEMParser(in2);
Everything appears to work fine until the line that creates a PEMParser runs. None of my code after this runs, yet I do not get any exception from this when using my application (Which is in Mule.)
Am I missing something here? Why would there be a problem with creating an instance of PEMParser from this code?
I'm no expert, but what you are showing does not look like a key in PEM format.
Compare with: http://www.herongyang.com/Cryptography/Certificate-Format-PEM-on-Certificates.html
This may help: https://sycure.wordpress.com/2008/05/15/tips-using-openssl-to-extract-private-key-pem-file-from-pfx-personal-information-exchange/