Skip to Main Content

Java Security

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Private Key and DER format

843811May 7 2008 — edited May 7 2008
Hi there,
I am generating a DER private key in the following manner.
KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
keyGen.initialize(2048); 
KeyPair keypair = keyGen.generateKeyPair();
Key privKey = keypair.getPrivate();

System.out.println("Private Key Format: " + privKey.getFormat());
byte[] derKey = privKey.getEncoded();
BufferedWriter out = new BufferedWriter(new FileWriter("priv.bin"));
out.write(new String(derKey));
out.close();
When I tried to use the following openSSL command to check the private key, I am getting error messages saying could not load the key.

openssl rsa -check -inform DER -in priv.bin

What might be the problem.

Thank you.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 4 2008
Added on May 7 2008
7 comments
1,203 views