我正在进行JBoss AS 5.1到7.4以及Java 6到7的迁移,但出现了握手失败的问题。
密钥库和信任库是我们长期以来一直使用的Java 6版本成功的那些。
我编写了一些测试来缩小问题范围,问题肯定不在于JBoss而是Java 7。
启用SSL日志记录后,我得到了以下信息:
17:44:30,041 INFO [stdout] (http-/192.168.147.20:8080-120) %% Invalidated: [Session-2, SSL_RSA_WITH_RC4_128_SHA]
17:44:30,041 INFO [stdout] (http-/192.168.147.20:8080-120) http-/192.168.147.20:8080-120, SEND TLSv1 ALERT: fatal, description = certificate_unknown
17:44:30,041 INFO [stdout] (http-/192.168.147.20:8080-120) http-/192.168.147.20:8080-120, WRITE: TLSv1 Alert, length = 2
17:44:30,041 INFO [stdout] (http-/192.168.147.20:8080-120) http-/192.168.147.20:8080-120, called closeSocket()
17:44:30,041 INFO [stdout] (http-/192.168.147.20:8080-120) http-/192.168.147.20:8080-120, handling exception: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path validation failed: java.security.cert.CertPathValidatorException: Path does not chain with any of the trust anchors
17:44:30,041 INFO [stdout] (http-/192.168.147.20:8080-120) http-/192.168.147.20:8080-120, called close()
17:44:30,042 INFO [stdout] (http-/192.168.147.20:8080-120) http-/192.168.147.20:8080-120, called closeInternal(true)
有一些讨论这个(或类似)问题的线程,人们建议使用不同的参数重新创建证书或信任存储库。我不想走这条路,因为我最近曾尝试为相同的webservice的不同帐户创建更多的密钥库和信任存储库,但没有成功。
由于我们一直在生产中使用这些旧的(密钥库和信任存储库)与Java 6,如果可能的话,我想保留它们。
看起来问题可能是由于Java 7在检查信任存储库证书链方面更加严格引起的?
是否可以设置一些标志放松检查,使其像Java 6一样运行?
我不确定如何解释失败消息:我认为它告诉我,不满足远程机器是安全的条件是我的计算机而不是远程服务器。这正确吗?
任何帮助/想法都将不胜感激!
==========================================================
按照建议,已将PEM(带有链)添加到信任存储库中,从Firefox访问WS URL时导出。这并没有让它握手成功,但稍微改变了失败情况。
***
%% Invalidated: [Session-1, SSL_RSA_WITH_RC4_128_SHA]
main, SEND TLSv1 ALERT: fatal, description = certificate_unknown
main, WRITE: TLSv1 Alert, length = 2
[Raw write]: length = 7
0000: 15 03 01 00 02 02 2E .......
main, called closeSocket()
main, handling exception: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1884)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:276)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:270)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1341)
at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:153)
at sun.security.ssl.Handshaker.processLoop(Handshaker.java:868)
at sun.security.ssl.Handshaker.process_record(Handshaker.java:804)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1016)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1312)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1339)
==============================================================
同时,如其他帖子中所建议的那样,我编写了另一个测试程序,使用了不验证证书链的TrustManager,并使用了我的原始信任库运行了该测试。
这个测试程序能够连接成功,从而表明我的机器对远程机器的验证是唯一的问题,而我的密钥库是正常的。
然而,我无法在我们实际的Web服务客户端中使用这种方法,因为它使用Sun RPC lib,连接操作发生在其代码的深处,所以我无法接触它。
==============================================================
openssl s_client -connect <server>:<port>
的输出。 - jww