Skip to content

Instantly share code, notes, and snippets.

@azzlack
Created April 30, 2015 14:33
Show Gist options
  • Save azzlack/7755bf6da8c74f6ac047 to your computer and use it in GitHub Desktop.
Save azzlack/7755bf6da8c74f6ac047 to your computer and use it in GitHub Desktop.
Create development certificate for domain with root CA
@echo off
echo.
echo #####################################
echo ## Development Certificate Factory ##
echo ## ##
echo ## by azzlack ##
echo #####################################
echo.
echo Loading paths...
CALL "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\VsDevCmd.bat"
echo.
echo Please enter a CA name:
echo Ex: "CN=MyRoot,O=MyOrganization,OU=MyUnit,L=MyLocality,S=MyProvince,C=MyCountry"
set /p ca= ""
echo.
echo Creating Certificate Authority
makecert -r -pe -n "%ca%" -ss CA -sr LocalMachine -a sha512 -len 4096 -sky signature -cy authority -sv root.pvk root.cer
echo Please enter the password for the CA certificate
set /p capass= ""
echo.
echo Generating PFX...
pvk2pfx -pvk root.pvk -spc root.cer -pfx root.pfx -pi %capass%
echo.
echo Please enter the domain to generate certificate for:
set /p domain= ""
echo Creating SSL certificate for %domain%
makecert -pe -n "CN=%domain%" -ss My -sr LocalMachine -a sha512 -len 4096 -sky Exchange -eku 1.3.6.1.5.5.7.3.1 -iv root.pvk -ic root.cer -sp "Microsoft RSA SChannel Cryptographic Provider" -sy 12 -sv domain.pvk domain.cer
echo Please enter the password for the domain certificate:
set /p domainpass= ""
echo.
echo Generating PFX...
pvk2pfx -pvk domain.pvk -spc domain.cer -pfx domain.pfx -pi %domainpass%
echo.
echo.
echo Finished
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment