0

我正在尝试获取此站点“ https://www.ssfcu.org/en-us/Pages/default.aspx ”的响应代码。代码片段是:

try{
     HttpURLConnection connection = pingUrl(location);
     responseCode = connection.getResponseCode();
}catch(Exception e) {
}

public HttpURLConnection pingUrl(String url) throws Exception{

    int count = 0;
    HttpURLConnection conn = null;

    conn = (HttpURLConnection) new URL(url).openConnection();
    conn.setRequestMethod("GET");
    conn.setConnectTimeout(2000);
    conn.setInstanceFollowRedirects(false);
    conn.setReadTimeout(10000);
    conn.connect();
    Thread.sleep(1000);

    return conn;
}

但我遇到了一个例外:

sun.security.validator.ValidatorException: PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException:
unable to find valid certification path to requested target

我该如何解决这个问题?

4

1 回答 1

1

旧的 COMODO 根证书已于 5 月 30 日到期。

https://www.reddit.com/r/linux/comments/gshh70/sectigo_root_ca_expiring_may_not_be_handled_well/

https://support.sectigo.com/articles/Knowledge/Sectigo-AddTrust-External-CA-Root-Expiring-May-30-2020

不知道这是否会影响 www.ssfcu.org,但您可以尝试将更新的证书导入您的 java 密钥库:

  1. 获取https://crt.sh/?d=1720081https://crt.sh/?d=1199354
  2. 将crt文件转换为der文件:openssl x509 -in 1720081.crt -outform der -out 1720081.der
  3. keytool -import -file 1720081.der -keystore your-keystore -alias Comodo(或别名 UserTrust 为 1199354)

您的密钥库位于文件 lib/security/cacerts 中的 JRE_HOME 目录中。您需要 root 权限才能编辑 cacerts 文件。

编辑:我仔细看了看,Comodo 没有参与 www.sfcu.org 的证书链,但只要您能识别已过期的根证书或中间证书,上述说明是正确的。我们今天碰巧遇到了linkedin.com 的问题。像 www.ssfcu.org 一样,他们也使用来自 DigiCert 的证书链,所以也许他们最近也有一些证书过期。

于 2020-06-01T15:46:03.647 回答