Self-Signed SSL Certificates
August 22nd, 2011
Introduction:
Abbreviated as Secure Sockets Layer, SSL is an encryption technology created by Netscape and is used to create an encrypted connection between your web server and web browser of the visitor, thereby building a pathway for private information to be transmitted without the problems of eavesdropping, data tampering, or message forgery. An SSL Certificate is required to be identified and installed on the server in order to enable SSL on a website. It is usually indicated by a padlock icon in web browsers but it can also be indicated by a green address bar. Upon having it installed, the site can be securely accessed by changing the URL from http:// to https://.
In order to establish an encrypted connection between a client and a server, an SSL certificate is are important. Webmasters build secure websites like e-commerce websites using encrypted connections, thereby preventing eavesdropping by providing extra protection.
Process of creating a self signed SSL Certificate:
SSL is said to use asymmetric cryptography or public key cryptography (PKI), where two keys are created, one public, one private. Anything which is encrypted with either of the two keys will only be decrypted with its corresponding key. Therefore if the private key of a server is used to encrypt a message or data stream, it can only be decrypted by using its corresponding public key, thereby ensuring that the data only could have come from the server. The following steps are to be followed to create a self-signed certificate:
Step 1: Generation of a Private Key:
In order to generate an RSA Private Key and CSR (Certificate Signing Request), the openssl toolkit is used, which can also be used to generate self-signed certificates for testing purposes or internal usage. The first step is to create your RSA Private Key, a 1024 bit RSA key which is encrypted using Triple-DES and stored in a PEM format so that it is readable as ASCII text. For this purpose, the following command may be used –
openssl genrsa -des3 -out server.key 1024
Step 2: Generation of a CSR (Certificate Signing Request):
Following the generation of a private key, a Certificate Signing Request (CSR) is to be generated. A CSR is reportedly used in one of two ways –
* First, it is sent to a Certificate Authority, such as Thawte or Verisign, wherein the requestor’s identity is verified, after which a signed certificate is issued.
* Second, the CSR is to be self-signed
A CSR may be generated by using the following command –
openssl req -new -key server.key -out server.csr
Step 3: Passphrase is removed from Key
One side-effect of the pass-phrased private key is that a pass-phrase is asked for each time the web server is started. Since it is inconvenient, an external program may be used in place of the built-in pass-phrase dialog, although it is not necessarily secure. The Triple-DES encryption can also be removed from the key, thereby eliminating the need to type in a pass-phrase. With the private key no longer encrypted, it is critical that only the root user reads this file. The corresponding certificate will need to be revoked, in case of a system compromise where a third party obtains the unencrypted private key. The following command may be used to remove the pass-phrase from the key:
cp server.key server.key.org
openssl rsa -in server.key.org -out server.key
Step 4: Generation of a Self-Signed Certificate
At this point, a self signed ssl certificate is to be generated. An error is generated in the client browser by this temporary certificate to the effect that the signing certificate authority is unknown and not trusted. The following command may be used to generate a temporary certificate –
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
Step 5: Installation of the Private Key and Certificate
With the installation of Apache with mod_ssl, several directories are created in the Apache config directory. The location of this directory will differ depending on how Apache was compiled.
cp server.crt /usr/local/apache/conf/ssl.crt
cp server.key /usr/local/apache/conf/ssl.key
Step 6: Configuration of SSL Enabled Virtual Hosts
SSLEngine on
SSLCertificateFile /usr/local/apache/conf/ssl.crt/server.crt
SSLCertificateKeyFile /usr/local/apache/conf/ssl.key/server.key
SetEnvIf User-Agent “.*MSIE.*” nokeepalive ssl-unclean-shutdown
CustomLog logs/ssl_request_log \
“%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \”%r\” %b”
Step 7: Restart Apache and Test
/etc/init.d/httpd stop
/etc/init.d/httpd stop
https://public.akadia.com