如何设置Jenkins CI以在Windows上使用https?

Nic*_*nes 46 windows ssl https continuous-integration jenkins

我们最近在Windows上设置了Jenkins CI服务器.现在,为了使用Active Directory身份验证,我想要求https(SSL/TLS)进行访问.鉴于此设置,建议的方法是什么?

afl*_*lat 35

转到%JENKINS_HOME%并修改jenkins.xml.你看到--httpPort=8080改变它的地方--httpPort=-1 --httpsPort=8080你可以把端口当作你想要的东西,但是在我的测试中(前一段时间,它可能已经改变了)如果你不保留--httpPort=<something>那么Jenkins总是会使用8080.所以如果你只是--httpPort=8080改为--httpsPort=8080,端口8080仍将使用http.

此外,如果您想使用自己的证书,本页底部还有一些说明.

http://wiki.jenkins-ci.org/display/JENKINS/Starting+and+Accessing+Jenkins


小智 18

跑:

keytool -genkey -keyalg RSA -keystore Jenkins.jks -alias [Name of website] -keysize 2048
Run Code Online (Sandbox Code Playgroud)

回答记住这First and last name是网站URL 的问题,并且应该是小写的.例:

build.jenkins-ci.org
Run Code Online (Sandbox Code Playgroud)

State or province 不能缩写.

跑:

keytool -certreq -Keystore jenkins.jks -alias [Name of website] -file jenkins.csr -keysize 2048
Run Code Online (Sandbox Code Playgroud)

发送Jenkins.csr给您的证书提供商并申请PKCS#7证书,该证书具有.p7b扩展名并以以下内容开头:

-----BEGIN PKCS #7 SIGNED DATA-----
Run Code Online (Sandbox Code Playgroud)

注意:试用证书通常不具有.p7b格式,但您可以.cer使用此工具组合文件,该工具报告成功但对我不起作用.(https://www.sslshopper.com/ssl-converter.html)

跑:

keytool -import -trustcacerts -file jenkins.p7b -keystore jenkins.jks -alias [Name of website]
Run Code Online (Sandbox Code Playgroud)

argumentsJenkins.xml中的节点更改为以下内容.

<arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%\jenkins.war" --httpPort=-1 --httpsPort=443 --httpsKeyStore="%BASE%\Cert\Jenkins.jks" --httpsKeyStorePassword=[Cert password from step 1]</arguments>
Run Code Online (Sandbox Code Playgroud)

故障排除:

  • 如果詹金斯没有开始阅读最后一行Jenkins.err.log.
  • 如果Jenkins由于问题没有启动Jenkins.xml,请用实际-(ASCII连字符)替换(奇怪的Windows连字符)字符.
  • 如果Jenkins启动但证书仍然显示为坏,请确保[Name of website]该实际URL没有https:示例:https://build.jenkins-ci.org将是build.jenkins-ci.org.
  • 如果不是问题,请.jks使用检查文件KeyStore Explorer."证书层次结构"应该表明每个证书都嵌套在另一个证书中; 这是为了说明证书链.如果它显示彼此相邻的证书,那么它是不正确的.
  • 如果它不会在特定端口(例如443)上启动,则验证IIS或其他应用程序当前未使用该端口.
  • 如果您可以在PC上看到它所托管的网站,而不是另一台PC,那么请确认您没有被防火墙阻止.