我正在尝试在Netbeans IDE上的项目上启用SSL并使用Glassfish应用程序服务器。
对于SSL;我按照下面的程序。
keytool -genkey -alias client_keystore -keyalg RSA -keystore client_keystore.jks -keysize 2048
keytool -certreq -alias client_keystore -file yourcsrname.csr -keystore client_keystore.jks
openssl x509 -outform der -in your-cert.pem -out your-cert.crt
keytool -import -trustcacerts -alias intermediate -file GoDaddy_Intermediate.crt -keystore client_keystore.jks
keytool -import -trustcacerts -alias root -file GoDaddy_Root.crt -keystore client_keystore.jks
keytool -import -trustcacerts -alias BizSwitch -file BizSwitch.crt -keystore client_keystore.jks
keytool -importkeystore -srckeystore ~/Downloads/ipay/client_keystore.jks -destkeystore keystore.jks
我不确定这是否全部,但我得到了sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
例外。
重新启动时,从glassfish日志中我看不到加载的证书。
我错过了什么吗?
你的密钥库是在/ domains / domain1 / config文件夹中吗?
看起来像glassfish没有指向正确的密钥库,因为您正确导入了证书。
您在别名client_keystore
下创建了密钥对条目,因此您需要将服务器证书导入该别名和条目。假设BizSwitch是您的服务器名称,您需要-importcert -file BizSwitch.crt -alias client_keystore -keystore client_keystore.jks
。如果你弄错了那个命令的输出应该是Certificate reply was installed
NOT Certificate was added
。 (后者适用于单独的CA证书,但不适用于服务器证书。)
此外,您不需要转换为DER。 keytool
(或者更确切地说是CertificateFactory
)已经能够阅读PEM证书超过十年,甚至是自2012年j7以来的PEM-comments评论。(对于其他一些加密对象,例如私钥,情况并非如此。)