安装 Tomcat SSL 证书失败

安装 Tomcat SSL 证书失败

我想建立一个使用 SSL 的网站。我使用 tomcat 8,并且已经使用自签名证书成功设置了 https,这当然在使用普通浏览器访问网站时会带来麻烦。然而,它运行良好,但并不适用于公共网站。

因此,我从官方供应商处购买了 SSL 证书。我下载了以下文件:

RapidSSL.crt  
RapidSSL.csr  
RapidSSL-Intermediate.cer

我在互联网上搜索如何正确安装它,但没有找到任何可行的方法。

我最近的尝试是执行以下操作:

keytool -import -trustcacerts -alias rapidSSL -file RapidSSL.crt -keystore rapidSSL.jks

然后我conf/server.xml通过改变现有条目进行了修改:

<Connector port="443" protocol="HTTP/1.1" SSLEnabled="true"
            keyAlias="rapidSSL"
            keystoreFile="/opt/SSL-Certificates/rapidSSL.jks"
            keypass="XYZ-Pass"
           maxThreads="150" scheme="https" secure="true"
           clientAuth="false" sslProtocol="TLS" 
           compression="on"
           compressionMinSize="2048"
           noCompressionUserAgents="gozilla, traviata"
           compressableMimeType="text/html,text/xml,text/x-json" />

启动服务器时出现以下异常:

16-Feb-2018 10:32:29.147 SEVERE [main] org.apache.coyote.AbstractProtocol.init Failed to initialize end point associated with ProtocolHandler ["http-nio-443"]
 java.io.IOException: Keystore was tampered with, or password was incorrect
    at sun.security.provider.JavaKeyStore.engineLoad(JavaKeyStore.java:780)
    at sun.security.provider.JavaKeyStore$JKS.engineLoad(JavaKeyStore.java:56)
    at sun.security.provider.KeyStoreDelegator.engineLoad(KeyStoreDelegator.java:225)
    at sun.security.provider.JavaKeyStore$DualFormatJKS.engineLoad(JavaKeyStore.java:70)
    at java.security.KeyStore.load(KeyStore.java:1445)
    at org.apache.tomcat.util.net.jsse.JSSESocketFactory.getStore(JSSESocketFactory.java:451)
    at org.apache.tomcat.util.net.jsse.JSSESocketFactory.getKeystore(JSSESocketFactory.java:355)
    at org.apache.tomcat.util.net.jsse.JSSESocketFactory.getKeyManagers(JSSESocketFactory.java:608)
    at org.apache.tomcat.util.net.jsse.JSSESocketFactory.getKeyManagers(JSSESocketFactory.java:548)
    at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:360)
    at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:742)
    at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:458)
    at org.apache.coyote.http11.AbstractHttp11JsseProtocol.init(AbstractHttp11JsseProtocol.java:120)
    at org.apache.catalina.connector.Connector.initInternal(Connector.java:960)
    at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
    at org.apache.catalina.core.StandardService.initInternal(StandardService.java:568)
    at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
    at org.apache.catalina.core.StandardServer.initInternal(StandardServer.java:851)
    at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
    at org.apache.catalina.startup.Catalina.load(Catalina.java:576)
    at org.apache.catalina.startup.Catalina.load(Catalina.java:599)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:310)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:484)
Caused by: java.security.UnrecoverableKeyException: Password verification failed
    at sun.security.provider.JavaKeyStore.engineLoad(JavaKeyStore.java:778)
    ... 26 more

所以,我真的不知道我在这里做错了什么。任何帮助都将不胜感激。谢谢 :)

编辑感谢您的回答,密钥密码绝对正确。

答案1

检查密钥传递。如果正确,则尝试重命名 rapidSSL.jks 并重新运行 keytool 以查看是否能解决问题。

相关内容