在 Java 中使用没有密码的 p12 文件 [英] Using a p12 file without a password in Java
问题描述
尽我所能,我不知道如何在 Java 中使用没有密码的 .p12 文件.我尝试将 javax.net.ssl.keyStorePassword
设置为 ""
但无论我做什么,我都会收到以下 SSL 错误:
HTTP 传输错误:javax.net.ssl.SSLHandshakeException:握手期间远程主机关闭连接
我所有的谷歌搜索都表明,sun 实现不允许使用空密码,当然 keytool 不会让您在没有商店密码的情况下导入任何证书.
Sun API 似乎需要密码,因此您需要在 .p12
文件中添加密码.>
这个页面说你可以用 openssl
做到这一点将 .p12
转换为 .pem
,然后转换回 .p12
(但我还没有尝试过):
openssl pkcs12 -in cert.p12 -out temp.pem -passin pass: -passout pass:temppasswordopenssl pkcs12 -export -in temp.pem -out cert-final.p12 -passin pass:temppassword -passout pass:newpasswordrm -f temp.pem
另见这个相关问题.
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.
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.
这篇关于在 Java 中使用没有密码的 p12 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!