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.