0
votes

I have a private key in PEM format, protected by a password (there is also a certificate for the key). Is it possible to import this key into a Java keystore without knowing it's password?

Knowing the password I would do the following:

openssl pkcs12 -export -in cert.pem -inkey key.pem > server.p12
keytool -importkeystore -srckeystore server.p12 -destkeystore server.jks -srcstoretype pkcs12

But I'd like to skip password input and re-use the existing password.

2
Stack Overflow is a site for programming and development questions. This question appears to be off-topic because it is not about programming or development. See What topics can I ask about here in the Help Center. Perhaps Super User or Unix & Linux Stack Exchange would be a better place to ask. Also see Where do I post questions about Dev Ops?jww

2 Answers

1
votes

No, the private key is encrypted, and the passphrase must be supplied to decrypt the key before it is imported.

0
votes

Not Possible.

The whole point of having the PrivateKey protected is to not let anyone gain access to it unless they know the password that unlocks it.