由于我的java应用程序在尝试创建具有特定https地址(https://barramento.caixa.gov.br/sibar/ManutencaoCobrancaBancaria/Boleto/Externo?xsd=xsd0)的https://barramento.caixa.gov.br/sibar/ManutencaoCobrancaBancaria/Boleto/Externo?xsd=xsd0时开始抛出一个异常,我一直在挣扎。
启用javax.net.debug之后,我发现问题的根本原因似乎是我试图连接到的服务器应用程序的证书链的长度。
在第一时间,我从TLS版本中怀疑,但是使用nmap,我能够找到服务器正在使用的TLS版本以及密码,而它们不是问题所在。服务器支持TLS1.1。我已经配置了我的服务器来使用这个版本,但是它根本没有帮助。
我在网上搜索了一些可能有用的信息,但是我在谷歌找不到任何东西,甚至没有找到接近"javax.net.ssl.SSLProtocolException:的证书链长度“”。
她是个累赘:
javax.net.ssl|FINE|26|http-nio-8080-exec-2|2020-11-06 17:30:36.178 BRT|Logger.java:765|READ: TLSv1.1 handshake, length = 3835
javax.net.ssl|SEVERE|26|http-nio-8080-exec-2|2020-11-06 17:30:36.188 BRT|Logger.java:765|Fatal (HANDSHAKE_FAILURE): Couldn't kickstart handshaking (
"throwable" : {
javax.net.ssl.SSLProtocolException: The certificate chain length (11) exceeds the maximum allowed length (10)
at sun.security.ssl.CertificateMessage$T12CertificateMessage.<init>(CertificateMessage.java:143)
at sun.security.ssl.CertificateMessage$T12CertificateConsumer.consume(CertificateMessage.java:363)
Caused by: javax.net.ssl.SSLProtocolException: The certificate chain length (11) exceeds the maximum allowed length (10)
at sun.security.ssl.CertificateMessage$T12CertificateMessage.<init>(CertificateMessage.java:143)
at sun.security.ssl.CertificateMessage$T12CertificateConsumer.consume(CertificateMessage.java:363)
at sun.security.ssl.SSLHandshake.consume(SSLHandshake.java:377)
at sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:444)
at sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:422)
at sun.security.ssl.TransportContext.dispatch(TransportContext.java:182)
at sun.security.ssl.SSLTransport.decode(SSLTransport.java:149)
at sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1143)
at sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1054)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:394)
这个post澄清了很多问题,并给了我一些理解问题的指导。但并没有被赋予。
注:奇怪的是,当使用Java1.8.0_272从ubuntu实例运行我的应用程序时,会发生这个问题。在Windows机器上运行我的应用程序(也使用1.8.0_272)时,不会发生这种情况。
是否有任何JVM参数或任何其他方式来设置允许的证书链的长度?
有人已经遇到过这样的情况了吗?
发布于 2020-11-11 00:26:18
正如@dave_thompson_085所指出的,实际的链只有4。问题是服务器发送了许多证书(@dave_thompson_085也指出了)。
添加"-Djdk.tls.maxCertificateChainLength=15“JVM参数解决了这个问题。
非常感谢@dave_thompson_085。
https://stackoverflow.com/questions/64721644
复制相似问题