If you, like me, want to use working (SSL) virtual domains with XAMPP, you need to do the following:
(I am on Windows, but a similar approach will work on other operating systems)
(If you want it the easy way, you can generate a valid certificate at https://ssl.indexnl.com/ , it saves you installling and working with OpenSSL)
First, add the domain to your Windows Hosts file, like:
- Code: Select all
127.0.0.1 www.testing.dom
Then, add the domain to your virtual host conf (\xampp\apache\conf\extra\httpd-vhosts.conf):
- Code: Select all
<VirtualHost *:80>
ServerAdmin webmaster@www.testing.dom
DocumentRoot "(your drive)\xampp\htdocs\www.testing.dom"
ServerName testing.dom
ServerAlias www.testing.dom
ErrorLog "logs/www.testing.dom-error.log"
CustomLog "logs/www.testing.dom-access.log" common
</VirtualHost>
Now the tricky part, getting SSL to work with that domain.
Fot this, you need to install OpenSSL for Windows.
Then, you first need to generate a root certificate.
Open OpenSSL command prompt (enter openssl, enter), and type:
- Code: Select all
genrsa -out myrootca.key 4096
This will be your private key for the root certificate.
Then type:
- Code: Select all
req -new -x509 -days 1826 -key myrootca.key -out myrootca.crt
You will be prompted with various details, just enter what it asks.
This will create your root certificate. (All files will be located in the bin directory)
You have to import this CA certificate. Double click it, click Install Certificate, and choose this location: Trusted Root Certificate Authorities Store
Now you have to generate a certificate and private key for your domain with OpenSSL and you have to sign this certificate with your new root certificate.
For the key type:
- Code: Select all
genrsa -out www.testing.dom.key 2048
Now you need to create a CSR (certificate signing request), type:
- Code: Select all
req -new -sha256 -key www.testing.dom.key -out www.testing.dom.csr -sha256
(Fill out all the fields, your FQDN must be testing.dom, dont use a password)
Now, create the certificate and sigh it with your root certificate
- Code: Select all
x509 -req -days 360 -in www.testing.dom.csr -CA myrootca.crt -CAkey myrootca.key -CAcreateserial -out www.testing.dom.crt -sha256
Thats it, now you have a valid certificate for testing.dom. Copy the certificate and key to your XAMPP installation, in apache\conf, ssl.crt and ssl.key
Then, add the SSL virtualhost to the (your drive)\xampp\apache\conf\extra\httpd-ssl.conf like this: (remove the entires of example.com in that file, they cause an error!)
- Code: Select all
<VirtualHost *:443>
ServerAdmin webmaster@www.testing.dom
DocumentRoot "(your drive)\xampp\htdocs\www.testing.dom"
ServerName testing.dom
ServerAlias www.testing.dom
SSLEngine on
SSLCertificateFile "(your drive)\xampp\apache\conf\ssl.crt\www.testing.dom.crt"
SSLCertificateKeyFile "(your drive)\xampp\apache\conf\ssl.key\www.testing.dom.key"
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
ErrorLog "logs/www.testing.dom-error.log"
CustomLog "logs/www.testing.dom-access.log" common
</VirtualHost>
Thats it!