Skip to content

Instantly share code, notes, and snippets.

@kenmasters
Last active January 21, 2022 08:31
Show Gist options
  • Save kenmasters/913b6f6bb885cb6ffe3f1d22b6831233 to your computer and use it in GitHub Desktop.
Save kenmasters/913b6f6bb885cb6ffe3f1d22b6831233 to your computer and use it in GitHub Desktop.
MAKE XAMPP SSL
Reference: https://shellcreeper.com/how-to-create-valid-ssl-in-localhost-for-xampp/
1. Create folder named: `C:\xampp\apache\crt`
2. Create files and store those file inside the newly created folder.
2.1 cert.conf
2.2 make-cert.bat
3. Edit cert.conf and Run make-cert.bat
Change {{DOMAIN}} text using the domain we want to use, in this case site.test and save.
Double click the make-cert.bat and input the domain site.test when prompted. And just do enter in other question since we already set the default from cert.conf
4. Install the cert in windows
After that, you will see site.test folder created. In that folder we will have server.crt and server.key. This is our SSL certificate.
Double click on the server.crt to install it on Windows so Windows can trust it.
And then select Local Machine as Store Location.
And then Select “Place all certificate in the following store” and click browse and select Trusted Root Certification Authorities.
And now this cert is installed and trusted in Windows. Next is how how to use this cert in XAMPP.
5. Add the site in Windows hosts
6. Add the site in XAMPP conf
C:\xampp\apache\conf\extra\httpd-xampp.conf
## site.test
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs"
ServerName site.test
ServerAlias *.site.test
</VirtualHost>
<VirtualHost *:443>
DocumentRoot "C:/xampp/htdocs"
ServerName site.test
ServerAlias *.site.test
SSLEngine on
SSLCertificateFile "crt/site.test/server.crt"
SSLCertificateKeyFile "crt/site.test/server.key"
</VirtualHost>
[ req ]
default_bits = 2048
default_keyfile = server-key.pem
distinguished_name = subject
req_extensions = req_ext
x509_extensions = x509_ext
string_mask = utf8only
[ subject ]
countryName = Country Name (2 letter code)
countryName_default = US
stateOrProvinceName = State or Province Name (full name)
stateOrProvinceName_default = NY
localityName = Locality Name (eg, city)
localityName_default = New York
organizationName = Organization Name (eg, company)
organizationName_default = Example, LLC
commonName = Common Name (e.g. server FQDN or YOUR name)
commonName_default = {{DOMAIN}}
emailAddress = Email Address
emailAddress_default = test@example.com
[ x509_ext ]
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid,issuer
basicConstraints = CA:FALSE
keyUsage = digitalSignature, keyEncipherment
subjectAltName = @alternate_names
nsComment = "OpenSSL Generated Certificate"
[ req_ext ]
subjectKeyIdentifier = hash
basicConstraints = CA:FALSE
keyUsage = digitalSignature, keyEncipherment
subjectAltName = @alternate_names
nsComment = "OpenSSL Generated Certificate"
[ alternate_names ]
DNS.1 = {{DOMAIN}}
@echo off
set /p domain="Enter Domain: "
set OPENSSL_CONF=../conf/openssl.cnf
if not exist .\%domain% mkdir .\%domain%
..\bin\openssl req -config cert.conf -new -sha256 -newkey rsa:2048 -nodes -keyout %domain%\server.key -x509 -days 3650 -out %domain%\server.crt
echo.
echo -----
echo The certificate was provided.
echo.
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment