我尝试通过 Jenkins Deploy to container 插件将 war 文件部署到远程机器,并且成功了。 tomcat URL 是 http://hostname:8080/ .后来我们在tomcat服务器上启用了SSL。现在,tomcat URL 是 https://hostname:8443 .将 war 文件推送到此启用 SSL 的 tomcat 服务器现在失败,出现以下异常。在 JENKINS 部署到容器插件中没有提及 SSL 证书的选项。
Caused by: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative names present
at sun.security.ssl.Alerts.getSSLException(Unknown Source)
at sun.security.ssl.SSLSocketImpl.fatal(Unknown Source)
at sun.security.ssl.Handshaker.fatalSE(Unknown Source)
at sun.security.ssl.Handshaker.fatalSE(Unknown Source)
at sun.security.ssl.ClientHandshaker.serverCertificate(Unknown Source)
at sun.security.ssl.ClientHandshaker.processMessage(Unknown Source)
at sun.security.ssl.Handshaker.processLoop(Unknown Source)
at sun.security.ssl.Handshaker.process_record(Unknown Source)
at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at sun.net.www.protocol.https.HttpsClient.afterConnect(Unknown Source)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(Unknown Source)
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.invoke(TomcatManager.java:534)
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.list(TomcatManager.java:686)
at org.codehaus.cargo.container.tomcat.internal.TomcatManager.getStatus(TomcatManager.java:699)
at org.codehaus.cargo.container.tomcat.internal.AbstractTomcatManagerDeployer.redeploy(AbstractTomcatManagerDeployer.java:174)
最佳答案
我首先移动了我的 cacerts 文件,以确保 Jenkins 确实尝试访问该文件。 在我批准 Jenkins 使用此文件后,我使用 Portecle 查看我的 cacerts 中的所有证书,然后导入丢失的证书:
因为我仍然遇到同样的错误,我意识到我忘记导入服务器本身的证书。我在 jenkins.xml 中找到了我的证书(我的 tomcat 和 Jenkins 在同一台服务器上运行)并将其放入我的 cacerts 和其他 .jks 文件中。
保存并重新启动所有服务后,它终于对我有用了。
关于Jenkins 通过 https 将 war 部署到 tomcat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49332979/