问题
Try as I might, I can't figure out how to use a .p12 file without a password in Java. I've tried setting javax.net.ssl.keyStorePassword
to ""
but whatever I do I get the following SSL error:
HTTP transport error: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
All my googling would suggest that the sun implementation will not allow an empty password and of course the keytool won't let you import any certificate without a password for the store.
回答1:
The Sun API seems to require a password, so you will instead need to add a password to your .p12
file.
This page says that you can do this with openssl
by converting the .p12
to a .pem
, then converting back to a .p12
(but I have not tried it):
openssl pkcs12 -in cert.p12 -out temp.pem -passin pass: -passout pass:temppassword
openssl pkcs12 -export -in temp.pem -out cert-final.p12 -passin pass:temppassword -passout pass:newpassword
rm -f temp.pem
See also this related question.
来源:https://stackoverflow.com/questions/20904657/using-a-p12-file-without-a-password-in-java