Self signed certificate


Voor Phpmyadmin maak ik gebruik van een https verbinding, dat betekent dus dat er een certificaat nodig is. Gelukkig is het mogelijk om een certificaat te maken die door jezelf ondertekend is. Voor prive doeleinden is dat prima geschikt.

Een aantal zaken zijn hier van belang:

  • de locatie van het certificaat
    Deze is terug te vinden in het configuratiebestand voor de website in de directory /etc/apache2/sites-enabled/.
  • de servernaam dient gelijk te zijn aan de common name die voor het certificaat gebruikt gaat worden

We kunnen aan de slag! Vorig jaar had ik er al een aangemaakt, maar deze moest vernieuwd worden. De stappen zijn:

roland:/etc/apache2/ssl# cd /etc/apache2/ssl
roland:/etc/apache2/ssl# openssl genrsa -out zomaarroland.nl.key 1024
Generating RSA private key, 1024 bit long modulus
..........++++++
.....++++++
e is 65537 (0x10001)
roland:/etc/apache2/ssl# chmod 600 zomaarroland.nl.key
roland:/etc/apache2/ssl# openssl req -new -key zomaarroland.nl.key -out zomaarroland.nl.key.csr
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (eg, YOUR name) []:
Email Address []:

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []: (no challenge)
An optional company name []:
roland:/etc/apache2/ssl# openssl x509 -req -days 365 -in zomaarroland.nl.key.csr -signkey zomaarroland.nl.key -out zomaarroland.nl.crt
Signature ok
subject=/C=../ST=../L=../O=../CN=Name/emailAddress=your@mail.com
Getting Private key
roland:/etc/apache2/ssl# mv apache.pem apache.pem.old
roland:/etc/apache2/ssl# cp zomaarroland.nl.key apache.pem
roland:/etc/apache2/ssl# cat zomaarroland.nl.crt >> apache.pem
roland:/etc/apache2/ssl# chmod 600 apache.pem

Nu is er alleen nog een herstart van Apache nodig en het vernieuwde certificaat is klaar!

roland:/etc/apache2/ssl# /etc/init.d/apache2 restart
Forcing reload of web server: Apache2.
roland:/etc/apache2/ssl#

Het mag duidelijk zijn dat de gegevens die ik heb ingevuld hier niet getoond worden.


Leave a Reply

Your email address will not be published. Required fields are marked *