我从godaddy购买了ssl证书,并且在配置它与Tomcat一起运行时遇到了一些麻烦。特别是我收到以下错误消息:
java.security.KeyStoreException: Cannot store non-PrivateKeys
Godaddy为证书提供了3个文件,我尝试将这些文件添加到密钥库中,如下所示:
keytool -import -alias root -keystore tomcat.keystore -trustcacerts -file gd_bundle-g2-g1.crt
keytool -import -alias intermed -keystore tomcat.keystore -trustcacerts -file gdig2.crt.pem
keytool -import -alias tomcat -keystore tomcat.keystore -trustcacerts -file <random hex string>.crt
我在这里找到:http://www.calamitycoder.com/WebSiteNotes/goDaddySHA2SSL.php
我已将Tomcat的server.xml配置为:
<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
keystoreFile="${user.home}/tomcat.keystore" keystorePass="password"
clientAuth="false" sslProtocol="TLS">
`
Tomcat版本是8.5.20。
非常感谢任何帮助。不确定这是否是Tomcat版本,因为在搜索数小时后我没有发现很多关于此错误的信息。 谢谢!
更新:
我删除了当前的密钥:
sudo keytool -delete -alias root -keystore tomcat.keystore
sudo keytool -delete -alias intermed -keystore tomcat.keystore
sudo keytool -delete -alias tomcat -keystore tomcat.keystore
并按照评论中的建议添加了密钥:
keytool -import -alias root -keystore tomcat.keystore -trustcacerts -file gd_bundle-g2-g1.crt
keytool -import -alias tomcat -keystore tomcat.keystore -file <random hex string>.crt
但遗憾的是发现了同样的错误:
Caused by: java.security.KeyStoreException: Cannot store non-PrivateKeys
at sun.security.provider.JavaKeyStore.engineSetKeyEntry(JavaKeyStore.java:258)
at sun.security.provider.JavaKeyStore$JKS.engineSetKeyEntry(JavaKeyStore.java:56)
at sun.security.provider.KeyStoreDelegator.engineSetKeyEntry(KeyStoreDelegator.java:117)
at sun.security.provider.JavaKeyStore$DualFormatJKS.engineSetKeyEntry(JavaKeyStore.java:70)
at java.security.KeyStore.setKeyEntry(KeyStore.java:1140)
at org.apache.tomcat.util.net.jsse.JSSEUtil.getKeyManagers(JSSEUtil.java:226)
我会继续玩这个,欢迎任何其他想法。谢谢!
答案 0 :(得分:0)
其他研究:
Godaddy Cert
CentOS 7.3.1611
仅更改 - Tomcat 8.5.20从8.5.3升级
CONF / server.xml中
org.apache.coyote.AbstractProtocol.init Failed to initialize end point associated with ProtocolHandler ["https-jsse-nio-8443"]
java.lang.IllegalArgumentException: java.security.KeyStoreException: Cannot store non-PrivateKeys
at org.apache.tomcat.util.net.AbstractJsseEndpoint.createSSLContext(AbstractJsseEndpoint.java:114)
at org.apache.tomcat.util.net.AbstractJsseEndpoint.initialiseSsl(AbstractJsseEndpoint.java:85)
at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:225)
适用于Tomcat 8.5.3但在8.5.20
CanHit
答案 1 :(得分:0)
将其更改为直接使用证书文件。并将密钥文件添加到配置中。
<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol" maxThreads="150" SSLEnabled="true" >
<UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" />
<SSLHostConfig>
<Certificate certificateKeyFile="conf/*.key"
certificateFile="conf/<random hex string>.crt"
certificateChainFile="conf/gd_bundle-g2-g1.crt"
type="RSA" />
</SSLHostConfig>
</Connector>
答案 2 :(得分:0)
自8.5.20以来,我的证书出现了同样的错误消息,我必须用
明确设置别名th:replace
在连接器中。在我添加别名之前,Tomcat尝试使用包含的CA证书并失败。