我有一个 SpringBoot 2 应用程序,在带有 Java8 Runtime 的 Tomcat 8.5 中运行。它正在为两个不同的证书/密钥使用 JKS 密钥库,这两个证书/密钥都被应用程序用于双向 TLS (mTLS)。
由于我们从 CA 管理员处检索了新版本的证书,因此一旦尝试客户端 mTLS 调用,应用程序就无法再使用密钥库,但出现以下异常。
Exception in thread "main" javax.net.ssl.SSLHandshakeException: Error signing certificate verify
at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1946)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:316)
at sun.security.ssl.ClientHandshaker.serverHelloDone(ClientHandshaker.java:1174)
at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:369)
at sun.security.ssl.Handshaker.processLoop(Handshaker.java:1037)
at sun.security.ssl.Handshaker.process_record(Handshaker.java:965)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1064)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1367)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1395)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1379)
at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:559)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:167)
at UrlEngine.submit(UrlEngine.java:52)
at JCurl.execute(JCurl.java:126)
at JCurl.main(JCurl.java:62)
Caused by: java.security.InvalidKeyException: No installed provider supports this key: sun.security.pkcs.PKCS8Key
at java.security.Signature$Delegate.chooseProvider(Signature.java:1138)
at java.security.Signature$Delegate.engineInitSign(Signature.java:1188)
at java.security.Signature.initSign(Signature.java:553)
at sun.security.ssl.HandshakeMessage$CertificateVerify.<init>(HandshakeMessage.java:1591)
at sun.security.ssl.ClientHandshaker.serverHelloDone(ClientHandshaker.java:1171)
... 13 more
我们已经从它的 PKCS12 源多次重建了密钥库,当使用导出的证书和密钥时,例如 curl,一切正常。