Tuesday, July 28, 2020

Configure Jenkins for Windows to use https using self signed certificate

1. Open Command Prompt window
2. cd \Program Files (x86)\Jenkins\jre\bin
3. Create self signed certificate: keytool -genkey -keyalg RSA -alias <hostname> -keystore jenkins.jks -validity 3650 -keysize 2048 -dname "CN=<company name>, OU=<organization unit>, O=<company name>, L=<city>, ST=<state>, C=US"
4. Move \Program Files (x86)\Jenkins\jre\bin\jenkins.jks to \Program Files (x86)\Jenkins\secrets\
5. Edit the C:\Program Files (x86)\Jenkins\jenkins.xml file and change the <arguments> block to:

<arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%\jenkins.war" --httpPort=-1 --httpsPort=8443 --httpsKeyStore="%BASE%\secrets\keystore" --httpsKeyStorePassword=your.password.here</arguments>

6. Stop and start the Jenkins service in the Services control panel