【发布时间】:2019-03-30 09:06:01
【问题描述】:
我有一个 Kotlin 程序,它使用 jsoup 从某个网站下载数据。在 IntelliJ IDEA 中测试它,它工作正常。当我生成一个 JAR 工件时,它会以 javax.net.ssl.SSLHandshakeException 失败。
我已经在 Windows 和 Linux 1.8 和 10 的多个 JRE 安装上测试过它,包括 IntelliJ 附带的副本,并且 JAR 每次都失败。该站点的根证书是 DigiCert Global Root G2,它似乎在我测试过的每个安装的 cacerts 中——指纹匹配等等。
我用-Djavax.net.debug=ssl 运行了JAR,它在输出末尾附近包含了这个;可根据要求提供更多摘录。
%% Invalidated: [Session-1, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256]
main, SEND TLSv1.2 ALERT: fatal, description = certificate_unknown
main, WRITE: TLSv1.2 Alert, length = 2
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
main, called close()
main, called closeInternal(true)
Exception in thread "main" 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(Unknown Source)
at ...
【问题讨论】:
-
尝试使用
-Djavax.net.debug=ssl运行以获取更多详细信息/日志。 -
@CrazyCoder 这是相当多的文字!我很乐意为这个问题添加更多细节,但我不确定哪些位是相关的。我猜 600 行“添加为受信任的证书......”大多是无关紧要的;我将首先添加一个看起来很有希望的摘录,然后在必要时添加更多。
标签: intellij-idea https jsoup sslhandshakeexception