self signed ssl
To generate self signed SSL certificate, run
1 2 |
openssl genrsa -out DOMAIN_NAME_HERE.key 2048 openssl req -new -x509 -key DOMAIN_NAME_HERE.key -out DOMAIN_NAME_HERE.crt -days 3650 -subj /CN=DOMAIN_NAME_HERE |
Or
1 |
openssl req -newkey rsa:2048 -nodes -keyout DOMAIN_NAME_HERE.key -x509 -days 3650 -out DOMAIN_NAME_HERE.crt |
Add Self Signed SSL to Apache Virtual Host
Lets say your Apache virtualhost entry is
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<VirtualHost *:80> ServerName serverok.in ServerAlias www.serverok.in ServerAdmin info@serverok.in DocumentRoot /home/serverok.in/public_html <Directory "/home/serverok.in/public_html"> Options All AllowOverride All Require all granted Order allow,deny allow from all </Directory> </VirtualHost> |
Create a new VirtualHost entry based on this, say yourdomain-ssl.conf, in this new file
Find
1 |
<VirtualHost *:80> |
Replace with
1 |
<VirtualHost *:443> |
Find line starting with
1 |
DocumentRoot |
Add Below
1 2 3 |
SSLEngine on SSLCertificateFile /etc/ssl/yourdomain.crt SSLCertificateKeyFile /etc/ssl/yourdomain.key |
Now restart Apache
1 |
systemctl restart apache2 |
How to access website using Self-signed SSL certificate
See SSL