Jenkins Windows slave认为我的证书无效

时间:2018-03-28 21:43:30

标签: java windows jenkins java-web-start jenkins-slave

遵循使用Java Web Start的文档,直到我在奴隶上运行此命令以连接到主服务器:

java -jar agent.jar -jnlpUrl https://my-server.com:8888/computer/myslave/slave-agent.jnlp -secret sdfsdfsdfsdf -workDir "c:\Jenkins"

我有一个有效的公共证书。从奴隶我可以访问https://my-server.com:8888,铬说证书有效,为什么詹金斯抱怨?当我为该死的东西付出了很多钱时,似乎愚蠢地使用-noCertificateCheck

  

2018年3月28日下午9:34:49 org.jenkinsci.remoting.engine.WorkDirManager   initializeWorkDir INFO:使用c:\​​ Jenkins \ remoting作为远程工作   目录将打印错误和输出日志   c:\ Jenkins \ remoting线程中的异常" main" java.io.IOException异常:   无法验证服务器证书。如果你正在使用   自签名证书,您可以使用-noCertificateCheck选项   绕过这个检查。           在hudson.remoting.Launcher.parseJnlpArguments(Launcher.java:548)           在hudson.remoting.Launcher.run(Launcher.java:322)           在hudson.remoting.Launcher.main(Launcher.java:283)引起:javax.net.ssl.SSLHandshakeException:   sun.security.validator.ValidatorException:PKIX路径构建失败:   sun.security.provider.certpath.SunCertPathBuilderException:无法   找到所请求目标的有效证明路径           在sun.security.ssl.Alerts.getSSLException(未知来源)           at sun.security.ssl.SSLSocketImpl.fatal(Unknown Source)           在sun.security.ssl.Handshaker.fatalSE(未知来源)           在sun.security.ssl.Handshaker.fatalSE(未知来源)           at sun.security.ssl.ClientHandshaker.serverCertificate(Unknown Source)           在sun.security.ssl.ClientHandshaker.processMessage(未知来源)           在sun.security.ssl.Handshaker.processLoop(未知来源)           在sun.security.ssl.Handshaker.process_record(未知来源)           at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)           at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)           在sun.security.ssl.SSLSocketImpl.startHandshake(未知来源)           在sun.security.ssl.SSLSocketImpl.startHandshake(未知来源)           在sun.net.www.protocol.https.HttpsClient.afterConnect(未知来源)           在sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(未知   资源)           在sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(未知   资源)           在hudson.remoting.Launcher.parseJnlpArguments(Launcher.java:490)           ... 2更多引起:sun.security.validator.ValidatorException:PKIX路径构建失败:   sun.security.provider.certpath.SunCertPathBuilderException:无法   找到所请求目标的有效证书路径           在sun.security.validator.PKIXValidator.doBuild(未知来源)           at sun.security.validator.PKIXValidator.engineValidate(Unknown Source)           at sun.security.validator.Validator.validate(Unknown Source)           at sun.security.ssl.X509TrustManagerImpl.validate(Unknown Source)           at sun.security.ssl.X509TrustManagerImpl.checkTrusted(Unknown Source)           at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(未知   资源)           ... 14更多引起:sun.security.provider.certpath.SunCertPathBuilderException:无法   找到所请求目标的有效证书路径           在sun.security.provider.certpath.SunCertPathBuilder.build(未知   资源)           在sun.security.provider.certpath.SunCertPathBuilder.engineBuild(未知   资源)           在java.security.cert.CertPathBuilder.build(未知来源)           ......还有20个

编辑: 所以我根本无法连接。如果我使用-noCertificateCheck我得到Incorrect acknowledgement sequence我假设因为我使用HTTPS而不验证证书

3 个答案:

答案 0 :(得分:1)

在您的问题中,您使用端口8888(https://my-server.com:8888)。我看过端口的jnlp脚本不存在或者是443。

当我看到像您这样的错误时,我将证书导入Java密钥库。有关详细信息here.

keytool -import -alias $ALIAS -keystore $JAVA_HOME/jre/lib/security/cacerts -file $PATH_TO_PEM_FILE

只有非自签名的公共证书才需要进行此导入,但您可以尝试。可能存在here解释的证书链。

答案 1 :(得分:1)

我的问题是我需要将整个证书链导入到Java密钥库中

像chrome这样的浏览器将遵循aia扩展并为您下载链,但是Java密钥库希望让您的生活更艰难。

答案 2 :(得分:0)

我尝试过

  1. 在salve 机器上更新Java 以获取Java 最新的信任存储。
  2. 使用公共 SSL (steps) 手动更新 Java 信任存储。

但上面没有任何效果。

最后,通过绕过以下命令末尾的 -noCertificateCheck,我能够从从属服务器连接到主服务器:

java -jar agent.jar -jnlpUrl https://example.com/computer/windows_slave/jenkins-agent.jnlp -secret [secret] -noCertificateCheck