Wednesday, January 16, 2013

How to generate self signed certificate on Apache Web Server (2.4) ?

How to generate self signed certificate on Apache Web Server (2.4)?
Step 1:
- Download Apache which have openssl bundle together as a package. You can go to http://www.apachelounge.com/download/
- Open command prompt and browse to the "APACHE_HOME\bin" folder
- Type in the command as shown below

openssl req -x509 -config "C:\Apache24\conf\openssl.cnf" -nodes -days 365 -newkey rsa:2048 -keyout "C:\Apache24\certificate\server.key" -out "C:\Apache24\certificate\server.crt"

Fill in all the relevant information.

Step 2:
- Go to "APACHE_HOME\conf" folder and open httpd.conf.
- Uncomment line
LoadModule ssl_module modules/mod_ssl.so
LoadModule vhost_alias_module modules/mod_vhost_alias.so
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so

Include conf/extra/httpd-vhosts.conf
Include conf/extra/httpd-ssl.conf

Step 3:
- Go to "APACHE_HOME\conf\extra" folder and open httpd-ssl.conf.

SSLCertificateFile "C:\Apache24\certificate\server.crt"
SSLCertificateKeyFile "C:\Apache24\certificate\server.key"

Tips:
To check the Apache configuration, - Open command prompt and browse to the "APACHE_HOME\bin" folder, type in the command "httpd -S".


Step 4:
- Go to "APACHE_HOME\conf\extra" folder and open httpd-vhosts.conf, edit the value of both of the virual host configuration

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host2.example.com
    DocumentRoot "C:\Apache24\htdocs"
    ServerName dummy-host2.example.com
    ErrorLog "logs/dummy-host2.example.com-error.log"
    CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>

<VirtualHost *:443>
ServerName www.domain.com
DocumentRoot "C:\Apache24\htdocs"
ServerName dummy-host2.example.com
SSLEngine on
SSLCertificateFile "C:\Apache24\certificate\server.crt"
SSLCertificateKeyFile "C:\Apache24\certificate\server.key"
</VirtualHost>

1 comment:

Unknown said...

Thanks for explaining this complete process. Earlier I tried to perform this but failed as I got stucked at a point. After learning all the steps I have to try it again.
digital certificates