“ sun.security.validator.ValidatorException:PKIX路径构建失败:异常:无法找到到所请求目标的有效证书路径”

问题描述 投票:0回答:1

我正在尝试获取此站点“ 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路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法找到到请求目标的有效证书路径

我该如何解决?

httpurlconnection pkix
1个回答
0
投票

[旧的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(或1199354的别名UserTrust)]

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

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

© www.soinside.com 2019 - 2024. All rights reserved.