jenkins There were errors checking the update sites: SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

Jenkins SSL问题解决方案

问题现象:

jenkins无法安装插件
出现如下错误
jenkins There were errors checking the update sites: SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

问题出现背景:

在安装jenkins的时候,使用的是jdk1.8不是使用的openjdk
SSL正式数显问题

解决方案

[root@duan ~]# find / -type f -name cacerts
/usr/java/jdk1.8.0_91/jre/lib/security/cacerts
/etc/pki/ca-trust/extracted/java/cacerts

找到系统的java证书

[root@duan ~]# cd /usr/local/jdk1.8.0_20/jre/lib/security/
[root@duan  security]# mv cacerts cacerts.bak
[root@duan security]# cp /etc/pki/ca-trust/extracted/java/cacerts ./

将证书复制到java的证书目录

测试

[root@duan ~]# wget https://confluence.atlassian.com/kb/files/779355358/779355357/1/1441897666313/SSLPoke.class
--2021-08-31 17:12:22--  https://confluence.atlassian.com/kb/files/779355358/779355357/1/1441897666313/SSLPoke.class
正在解析主机 confluence.atlassian.com (confluence.atlassian.com)... 99.84.48.31, 99.84.48.79, 99.84.48.92, ...
正在连接 confluence.atlassian.com (confluence.atlassian.com)|99.84.48.31|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1959 (1.9K) [application/octet-stream]
正在保存至:SSLPoke.class100%[=============================================================================================================================================================================================================>] 1,959       --.-K/s 用时 0s      

2021-08-31 17:12:25 (430 MB/s) - 已保存 “SSLPoke.class[1959/1959])
[root@duan ~]# $JAVA_HOME/bin/java SSLPoke updates.jenkins.io 443

Successfully connected

这样证书就生效了

如果有问题,则出现这样的错误提示

[root@duan ~]# $JAVA_HOME/bin/java SSLPoke updates.jenkins.io 443
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.validator.PKIXValidator.doBuild(PKIXValidator.java:387)
        at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:292)
        at sun.security.validator.Validator.validate(Validator.java:260)
        at sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:324)
        at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:229)
        at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:124)
        at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1491)
        at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:216)
        at sun.security.ssl.Handshaker.processLoop(Handshaker.java:979)
        at sun.security.ssl.Handshaker.process_record(Handshaker.java:914)
        at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1062)
        at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375)
        at sun.security.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:747)
        at sun.security.ssl.AppOutputStream.write(AppOutputStream.java:123)
        at sun.security.ssl.AppOutputStream.write(AppOutputStream.java:138)
        at SSLPoke.main(SSLPoke.java:31)
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
        at sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:141)
        at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:126)
        at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:280)
        at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:382)
        ... 15 more

重启jenkins

问题得到解决

参考文章:https://www.cnblogs.com/tanghu/p/12869658.html

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐