How to create a Self-Signed SSL Certificate

Step 1: Generate a Private Key

[root@esjeruk:/home/server] openssl genrsa -des3 -out server.key 1024
Generating RSA private key, 1024 bit long modulus
..++++++
.......................++++++
e is 65537 (0x10001)

Enter pass phrase for server.key:
Verifying - Enter pass phrase for server.key:

 

Step 2: Generate a CSR (Certificate Signing Request)

[root@esjeruk:/home/server] openssl req -new -key server.key -out server.csr
Enter pass phrase for server.key:

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) [GB]:ID
State or Province Name (full name) [Berkshire]:Jakarta
Locality Name (eg, city) [Newbury]:Jakarta
Organization Name (eg, company) [My Company Ltd]:Esjeruk
Organizational Unit Name (eg, section) []:Esjeruk
Common Name (eg, your name or your server's hostname) []:esjeruk
Email Address []:support@esjeruk.org
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:esjeruk
An optional company name []:

 

Step 3: Remove Passphrase from Key

[root@esjeruk:/home/server] cp server.key server.key.org
[root@esjeruk:/home/server] openssl rsa -in server.key.org -out server.key
Enter pass phrase for server.key.org:
writing RSA key

 

Step 4: Generating a Self-Signed Certificate

[root@esjeruk:/home/server] openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
Signature ok
subject=/C=ID/ST=Jakarta/L=Jakarta/O=Esjeruk/OU=Esjeruk/CN=esjeruk/emailAddress=support@esjeruk.org
Getting Private key

 

Step 5: Installing the Private Key and Certificate

[root@esjeruk:/home/server] cp server.crt /usr/local/apache/conf/ssl.crt
[root@esjeruk:/home/server] cp server.key /usr/local/apache/conf/ssl.key

 

Step 6: Configuring SSL Enabled Virtual Hosts

SSLEngine on
SSLCertificateFile /usr/local/apache/conf/ssl.crt/server.crt
SSLCertificateKeyFile /usr/local/apache/conf/ssl.key/server.key

 

Step 7: Restart Apache and Test

[root@esjeruk:/home/server] /etc/init.d/httpd restart

Post to Twitter

This entry was posted in apache, https, ssl. Bookmark the permalink.

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>