Skip to content

Instantly share code, notes, and snippets.

@Tynael
Last active March 13, 2025 18:57
Show Gist options
  • Save Tynael/d3a647c71bb00f0442590e6d91285a4e to your computer and use it in GitHub Desktop.
Save Tynael/d3a647c71bb00f0442590e6d91285a4e to your computer and use it in GitHub Desktop.
How to Set up an SSL Certificate in Localhost for XAMPP

How to Set up an SSL Certificate in Localhost for XAMPP

These files represent the content that has been modified during the tutorial.

To better understand the context, go through the video and/or written tutorial.

# xampp/apache/conf/extra/httpd-vhosts.conf
<VirtualHost *:80>
ServerName localvaren.com
ServerAlias localvaren.com
DocumentRoot "G:/xampp/htdocs/varen/public"
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.localvaren.com [OR]
RewriteCond %{SERVER_NAME} =localvaren.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
<VirtualHost *:443>
ServerName localvaren.com
ServerAlias localvaren.com
DocumentRoot "G:/xampp/htdocs/varen/public"
SSLEngine on
SSLCertificateFile "conf/ssl.crt/server.crt"
SSLCertificateKeyFile "conf/ssl.key/server.key"
</VirtualHost>
# xampp/apache/conf/httpd.conf
# The following lines must be uncommented. Remove the preceeding "#".
LoadModule ssl_module modules/mod_ssl.so
Include conf/extra/httpd-ssl.conf
...
bin\openssl x509 -in server.csr -out server.crt -req -signkey server.key -days 1825 -extfile v3.ext
...
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
subjectAltName = @alt_names
[alt_names]
DNS.1 = localhost
DNS.2 = *.localvaren.com
DNS.3 = localvaren.com
DNS.4 = 127.0.0.1
DNS.5 = 127.0.0.2
@Tynael
Copy link
Author

Tynael commented Sep 19, 2024

@JesperKnez Have you tried with a different browser such as Google Chrome?

@mohammedshajin
Copy link

This not working outside the server

@Tynael
Copy link
Author

Tynael commented Oct 7, 2024

@mohammedshajin As mentioned in the tutorial, the solution is meant to be used only in the context of local development.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment