Skip to content

Instantly share code, notes, and snippets.

@nordineb
Forked from mikeblakeuk/AddCerts.cmd
Created June 9, 2016 12:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nordineb/3b28c9f56b1cdd120f5e318266b5ed87 to your computer and use it in GitHub Desktop.
Save nordineb/3b28c9f56b1cdd120f5e318266b5ed87 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