gpt4 book ai didi

java - Tomcat 失败并出现 UnrecoverableKeyException : Cannot recover key

转载 作者:行者123 更新时间:2023-11-28 21:55:41 24 4
gpt4 key购买 nike

我在服务器上运行 Apache Tomcat/7.0.68,我正在尝试为其自动更新证书。

证书和私钥是通过 Java 的 keytool 从 PKCS#12 文件(Powershell 脚本摘录)导入的:

& $keytool -importkeystore -srckeystore $certfile -srcstoretype PKCS12 -srcstorepass $srcpassword -srcalias tomcat -keystore $keystore -deststorepass $dstpassword -destalias teamcity -destkeypass $dstpassword -noprompt

当我重新启动 Tomcat 时,它吐出以下日志行:

INFO: Initializing ProtocolHandler ["http-nio-443"]
jul. 14, 2017 5:03:31 PM org.apache.coyote.AbstractProtocol init
SEVERE: Failed to initialize end point associated with ProtocolHandler ["http-nio-443"]
java.security.UnrecoverableKeyException: Cannot recover key
at sun.security.provider.KeyProtector.recover(KeyProtector.java:328)
at sun.security.provider.JavaKeyStore.engineGetKey(JavaKeyStore.java:146)
at sun.security.provider.JavaKeyStore$JKS.engineGetKey(JavaKeyStore.java:56)
at sun.security.provider.KeyStoreDelegator.engineGetKey(KeyStoreDelegator.java:96)
at sun.security.provider.JavaKeyStore$DualFormatJKS.engineGetKey(JavaKeyStore.java:70)
at java.security.KeyStore.getKey(KeyStore.java:1023)
at sun.security.ssl.SunX509KeyManagerImpl.<init>(SunX509KeyManagerImpl.java:133)
at sun.security.ssl.KeyManagerFactoryImpl$SunX509.engineInit(KeyManagerFactoryImpl.java:70)
at javax.net.ssl.KeyManagerFactory.init(KeyManagerFactory.java:256)
at org.apache.tomcat.util.net.jsse.JSSESocketFactory.getKeyManagers(JSSESocketFactory.java:608)
at org.apache.tomcat.util.net.jsse.JSSESocketFactory.getKeyManagers(JSSESocketFactory.java:537)
at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:495)
at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:650)
at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:434)
at org.apache.coyote.http11.AbstractHttp11JsseProtocol.init(AbstractHttp11JsseProtocol.java:119)
at org.apache.catalina.connector.Connector.initInternal(Connector.java:978)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
at org.apache.catalina.core.StandardService.initInternal(StandardService.java:560)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
at org.apache.catalina.core.StandardServer.initInternal(StandardServer.java:820)
at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
at org.apache.catalina.startup.Catalina.load(Catalina.java:642)
at org.apache.catalina.startup.Catalina.load(Catalina.java:667)
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:253)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:427)

但是当我尝试通过 keytool 更改密码时,它可以正常读取条目并更改密码。

PS:我确保条目的密码与商店的密码相同,因为至少某些版本的 Tomcat 需要这个。

最佳答案

终于解决了。事实证明,在 keystore 中使用与 keystore 不同的密码的完全不相关的 key 会破坏 Tomcat,详见 this ancient bug report。 !

关于java - Tomcat 失败并出现 UnrecoverableKeyException : Cannot recover key,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45107095/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com