[关闭]
@TedZhou 2024-09-06T15:02:19.000000Z 字数 880 阅读 38

更新网站ssl证书导致java httpclient请求出错的问题

ssl java jdk keytool

错误

httpClient.executeMethod(method)出错如下:

  1. javax.net.ssl.SSLHandshakeException:
  2. sun.security.validator.ValidatorException:
  3. PKIX path building failed:
  4. sun.security.provider.certpath.SunCertPathBuilderException:
  5. unable to find valid certification path to requested target

原因

由于Mozilla更新了其根证书信任策略,即对于全球所有CA的可信根证书生成后最少15年更换一次,超过时间的可信根将会逐步被Mozilla停止信任,因此Digicert的部分老根证书将会在2023年07月01日左右逐步升级为Digicert Global Root G2。

也就是说新证书的根证书变了。我的老java应用的jre带的security/cacerts没有自带Digicert Global Root G2

解决方法

从浏览器导出"Digicert Global Root G2.crt",然后导入到用到的java jre中:

  1. keytool -importcert -file '/pathto/DigiCert Global Root G2.crt' -keystore '/pathto/jre/lib/security/cacerts' -storepass changeit

然后重启java应用即可。

freessl.cn 申请的免费证书也有类似的问题

只是根证书改为:TrustAsia ECC DV TLS CA G3

参考

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注