Apache 2: Self-Signed Certificates-ssl
Self-signed certificates are very useful when doing testing on your local machine. The following was tested using a unix based environment.
Generate the Key and Certificate First we generate the private key
openssl genrsa -des3 -out server.key 1024
Then we create a certificate signing request
openssl req -new -key server.key -out server.csr
We make sure that everytime we start the apache server, we don’t have to type the passphrase
cp server.key server.key.org openssl rsa -in server.key.org -out server.key
Lastly we self-sign the certificate
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
Configure the Apache Server Edit your apache’s httpd.conf and uncomment the following lines (just search it in the file)
LoadModule ssl_module modules/mod_ssl.so #PATH MAY DIFFER TO YOUR SETUP
Include conf/extra/httpd-ssl.conf Next edit your apache’s httpd-ssl.conf,
search for the following configuration item:
SSLCertificateFile & SSLCertificateKeyFile, change it to where your server.crt and server.key files are located respectively (absolute path!)
Finally if you’re using VirtualHost it is important to declare two NameVirtualHost (one for port 80 and port 443). Example: NameVirtualHost
ServerName local.example.com
DocumentRoot /path/to/your/example.com/www
ServerName local.example.com
DocumentRoot /path/to/your/example.com/www
SSLEngine on SSLCertificateFile /path/to/your/server.crt
SSLCertificateKeyFile /path/to/your/server.key
Save and restart your Apache server!