@echo off

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

set /p refno="Enter Reference Number: "
echo %refno%

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

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

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

rem display content using
rem %OPENSSL%\openssl req -text -in %refno%.csr -noout

pause

