1@echo off 2REM We need admin rights, otherwise the random state cannot be written 3REM Thanks to http://stackoverflow.com/a/10052222/1531708 4 5:: BatchGotAdmin 6:------------------------------------- 7REM --> Check for permissions 8 IF "%PROCESSOR_ARCHITECTURE%" EQU "amd64" ( 9>nul 2>&1 "%SYSTEMROOT%\SysWOW64\cacls.exe" "%SYSTEMROOT%\SysWOW64\config\system" 10) ELSE ( 11>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system" 12) 13 14REM --> If error flag set, we do not have admin. 15if '%errorlevel%' NEQ '0' ( 16 echo Requesting administrative privileges... 17 goto UACPrompt 18) else ( goto gotAdmin ) 19 20:UACPrompt 21 echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs" 22 set params = %*:"="" 23 echo UAC.ShellExecute "cmd.exe", "/c ""%~s0"" %params%", "", "runas", 1 >> "%temp%\getadmin.vbs" 24 25 "%temp%\getadmin.vbs" 26 del "%temp%\getadmin.vbs" 27 exit /B 28 29:gotAdmin 30 pushd "%CD%" 31 CD /D "%~dp0" 32:-------------------------------------- 33 34del server.* 35 36c:\OpenSSL-Win32\bin\openssl.exe genrsa -des3 -out server.key 4096 37 38c:\OpenSSL-Win32\bin\openssl.exe req -sha256 -new -key server.key -out server.csr -utf8 39 40copy server.key server.key.orig 41 42c:\OpenSSL-Win32\bin\openssl.exe rsa -in server.key.orig -out server.key 43 44echo [ v3_ca ] > server.ext.txt 45echo [ req ] >> server.ext.txt 46echo req_extensions = my_extensions >> server.ext.txt 47echo [ my_extensions ] >> server.ext.txt 48echo extendedKeyUsage=serverAuth >> server.ext.txt 49echo crlDistributionPoints=URI:http://localhost/crl.pem >> server.ext.txt 50 51c:\OpenSSL-Win32\bin\openssl.exe x509 -req -days 365 -extensions v3_ca -extfile server.ext.txt -in server.csr -signkey server.key -out server.crt 52 53copy server.crt server.pem 54 55type server.key >> server.pem 56