Skip to content

Instantly share code, notes, and snippets.

@mikeblakeuk
Last active June 9, 2016 12:39
Show Gist options
  • Save mikeblakeuk/57ca299c5b8c34333036 to your computer and use it in GitHub Desktop.
Save mikeblakeuk/57ca299c5b8c34333036 to your computer and use it in GitHub Desktop.
Getting HTTPS to work on TeamCity Agents with a self cert pfx
echo For my cloud agents, I had to get the pfx alias, Import the CARoot.cer, merge the pfx, and then change the password.
echo Based on https://github.com/haron/startssl-java and https://docs.oracle.com/javase/6/docs/technotes/tools/windows/keytool.html
cd %~dp0
set JAVA_HOME=C:\BuildAgent\jre
set KEYTOOL=%JAVA_HOME%\bin\keytool
set KEYSTORE=%JAVA_HOME%\lib\security\cacerts
set PASSWORD=changeit
echo "Importing StartSSL certificates into %KEYSTORE%" > run.log
rem C:\BuildAgent>jre\bin\keytool -list -keystore .\conf\ssl\build.cloudapp.net.pfx -storetype pkcs12
"%KEYTOOL%" -import -trustcacerts -keystore "%KEYSTORE%" -storepass %PASSWORD% -noprompt -alias caroot -file ./conf/ssl/CARoot.cer >> run.log
"%KEYTOOL%" -importkeystore -srckeystore ./conf/ssl/build.cloudapp.net.pfx -destkeystore "%KEYSTORE%" -alias {get using list} -destalias build -srcstoretype pkcs12 -srcstorepass {youpassword} -deststorepass %PASSWORD% -noprompt >> run.log
"%KEYTOOL%" -keypasswd -alias build -keypass {yourpassword} -new %PASSWORD% -keystore "%KEYSTORE%" -storepass %PASSWORD% -noprompt >> run.log
"%KEYTOOL%" -list -keystore "%KEYSTORE%" -storepass %PASSWORD% -noprompt >> run.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment