Recently I had to do this task twice in the last month at different localhosts, so I’m writing this post as a personal note (all this blog is meant to be a sort of memo book, though).
First, create the certificates:
sudo openssl genrsa -out localhost.key 1024
sudo openssl req -new -key localhost.key -x509 -out localhost.crt
sudo chmod 600 localhost.*
Then edit /etc/apache2/sites-available/default-ssl and put the important parts:
Finally activate SSL and reload Apache:
sudo a2enmod ssl
sudo a2ensite default-ssl
sudo service apache2 reload
PS: These tips are for development pruposes. In production you’ll need a chained certificate (aka certificate bundle).