@echo off

set OPENSSL=%~dp0%\..\OpenSSL-Win64\bin
set OPENSSL_CONF=%~dp0%\..\OpenSSL-Win64\bin\openssl.cfg

set /p cn="Enter Certificate Name (FQDN): "
echo %cn%

rem generate private key
%OPENSSL%\openssl genpkey -config %OPENSSL_CONF% -quiet -out %cn%.key -algorithm RSA -pkeyopt rsa_keygen_bits:2048 

rem dispaly key content
rem %OPENSSL%\openssl pkey -config  -in %cn%.key -text -noout

rem generate certificate request CSR
%OPENSSL%\openssl req -config %OPENSSL_CONF% -new -key %cn%.key -out %cn%.csr -subj "/C=CA/ST=Ontario/L=Toronto/O=Ontario Health/CN=%cn%"

rem display Certificate request
rem %OPENSSL%\openssl req -text -in %cn%.csr -noout

pause

