【问题标题】:Why am I getting an SSLHandshakeException as a JAR when the program works in IntelliJ?当程序在 IntelliJ 中运行时,为什么我会收到 SSLHandshakeException 作为 JAR?
【发布时间】: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


【解决方案1】:

对于 IntelliJ-IDEA,使用内置的信任证书插件:

https://www.jetbrains.com/help/idea/settings-tools-server-certificates.html

它还有一个复选框,可以让您忽略证书。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-20
    • 2012-05-31
    • 1970-01-01
    • 1970-01-01
    • 2012-08-28
    • 1970-01-01
    相关资源
    最近更新 更多