Skip to content

Instantly share code, notes, and snippets.

@grandsilence
Last active March 21, 2021 21:25
Show Gist options
  • Save grandsilence/9f3e92ba8fcc62356ff8e7d006072242 to your computer and use it in GitHub Desktop.
Save grandsilence/9f3e92ba8fcc62356ff8e7d006072242 to your computer and use it in GitHub Desktop.
RUN AS ADMIN! Copy near generate.bat (OSPanel\modules\http\<YOUR SETUP>\conf)
@echo off
set OPENSSL_CONF=%~dp0..\conf\openssl.cnf
..\bin\openssl req -x509 -sha256 -newkey rsa:2048 -nodes -days 5475 -keyout rootCA.key -out rootCA.crt -subj "/CN=OSPanel/"
..\bin\openssl req -newkey rsa:2048 -nodes -days 5475 -keyout server.key -out server.csr -subj "/CN=PhpStorm/"
..\bin\openssl x509 -req -sha256 -days 5475 -in server.csr -extfile v3.txt -CA rootCA.crt -CAkey rootCA.key -CAcreateserial -out server.crt
..\bin\openssl dhparam -out dhparam.pem 2048
@echo off
title Copy to userdata and install certs
set CURRENTDIR=%~dp0
set OSPATH=%CURRENTDIR%..\..\..\..\userdata\config\cert_files
xcopy /y "%CURRENTDIR%dhparam.pem" "%OSPATH%"
xcopy /y "%CURRENTDIR%rootCA.crt" "%OSPATH%"
xcopy /y "%CURRENTDIR%rootCA.key" "%OSPATH%"
xcopy /y "%CURRENTDIR%rootCA.srl" "%OSPATH%"
xcopy /y "%CURRENTDIR%server.crt" "%OSPATH%"
xcopy /y "%CURRENTDIR%server.csr" "%OSPATH%"
xcopy /y "%CURRENTDIR%server.key" "%OSPATH%"
certutil -enterprise -f -v -AddStore "Root" "%OSPATH%\rootCA.crt"
certutil -enterprise -f -v -AddStore "Root" "%OSPATH%\server.crt"
pause
nsComment = "Open Server Panel Generated Certificate"
basicConstraints = CA:false
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid,issuer
keyUsage = nonRepudiation, digitalSignature, keyEncipherment
subjectAltName = @alt_names
[alt_names]
DNS.1 = localhost
DNS.2 = yoursite.loc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment