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

发布于 2024-10-22 05:14:47 字数 111 浏览 1 评论 0原文

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

We've recently set up a Jenkins CI server on Windows. Now in order to use Active Directory authentication I'd like to require https (SSL/TLS) for access. Given this setup, what is the recommended way to do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

故笙诉离歌 2024-10-29 05:14:47

转到 %JENKINS_HOME% 并修改 jenkins.xml。在您看到 --httpPort=8080 的地方将其更改为 --httpPort=-1 --httpsPort=8080 当然,您可以将端口设置为您想要的任何端口,但在我的测试(不久前,它可能已更改)如果您不保留 --httpPort= 那么 Jenkins 将始终使用 8080。因此,如果您只需更改 --httpPort =8080 改为 --httpsPort=8080,端口 8080 仍将使用 http。

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

http://wiki.jenkins-ci.org/display/JENKINS /启动+和+访问+Jenkins

Go to your %JENKINS_HOME% and modify the jenkins.xml. Where you see --httpPort=8080 change it to --httpPort=-1 --httpsPort=8080 you can make the ports anything you want of course, but in my testing (a while ago, it may have changed) if you don't keep --httpPort=<something> then Jenkins will always use 8080. So if you simply change --httpPort=8080 to --httpsPort=8080, port 8080 will still use http.

Also, if you want to use your own certificate, there are some instructions at the bottom of this page.

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

我不是你的备胎 2024-10-29 05:14:47

运行:

keytool -genkey -keyalg RSA -keystore Jenkins.jks -alias [Name of website] -keysize 2048

回答问题,记住名字和姓氏是网站 URL,并且应该是小写。示例:

build.jenkins-ci.org

州或省不能缩写。

运行:

keytool -certreq -Keystore jenkins.jks -alias [Name of website] -file jenkins.csr -keysize 2048

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

-----BEGIN PKCS #7 SIGNED DATA-----

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

运行:

keytool -import -trustcacerts -file jenkins.p7b -keystore jenkins.jks -alias [Name of website]

将 Jenkins.xml 中的 arguments 节点更改为以下内容。

<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>

故障排除:

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

Run:

keytool -genkey -keyalg RSA -keystore Jenkins.jks -alias [Name of website] -keysize 2048

Answer the questions remembering that First and last name is the website URL and should be lowercase. Example:

build.jenkins-ci.org

State or province cannot be abbreviated.

Run:

keytool -certreq -Keystore jenkins.jks -alias [Name of website] -file jenkins.csr -keysize 2048

Send Jenkins.csr to your cert provider and request a PKCS#7 cert which has a .p7b extension and starts with:

-----BEGIN PKCS #7 SIGNED DATA-----

Note: Trial certs are not normally available in .p7b format but you may be able to combine the .cer files using this tool which reported success but didn't work for me. (https://www.sslshopper.com/ssl-converter.html)

Run:

keytool -import -trustcacerts -file jenkins.p7b -keystore jenkins.jks -alias [Name of website]

Change the arguments node in Jenkins.xml to the following prespectivly.

<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>

Troubleshooting:

  • If Jenkins doesn't start read the last lines from Jenkins.err.log.
  • If Jenkins didn't start because of an issue with Jenkins.xml, replace the (weird Windows hyphen) characters with an actual - (ASCII hyphen).
  • If Jenkins starts but the cert still reads as bad, make sure the [Name of website] is the actual URL without the https: example: https://build.jenkins-ci.org would be build.jenkins-ci.org.
  • If that isn't the issue inspect the .jks file using KeyStore Explorer. The "Certificate Hierarchy" should show that each cert is nested in another; This is to illustrate the cert chain. If it shows the certs next to each other then it's not correct.
  • If it won't start on a specific port, 443 for example, then verify IIS or another app isn't currently using the port.
  • If you can see the site on the PC it's hosted on, but not another PC, then verify you aren't getting blocked by a firewall.
女皇必胜 2024-10-29 05:14:47

第 1 步:在您的 jenkin 名称上创建公共和私有证书(如果不是,请将它们转换为 keyore 文件)
步骤2:将公共证书导入浏览器证书管理器(导入到所有选项卡)
第三步:使用包含公钥和私钥的 JKS 文件托管 jenkin。

有关步骤,请参阅“在 jenkins 中启用 HTTPS?

Step1: Create both public and private Certificate on your jenkin name (convert them into keysore file if its not)
Step2: Import the public certificate into your browser certificate mananger (import into all tabs)
Step3: Host your jenkin using JKS file which contain both public and private key.

For steps refer "Enable HTTPS in jenkins?"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文