Tuesday, May 17, 2011

How to enable secure http (https) in your localmachine

To enable https in your local machine is not a tough game , its simple .
I have performed only few steps in my ubuntu ,just check it out

  • openssl genrsa -out yourX.key 1024
  • openssl req -new -key yourX.key -out yourX.csr
  • openssl req -new -key yourX.key -x509 -out yourX.crt -days 365

Run these 3 commands inside a folder , 'yourX' should be replaced with your application name .These commands will generate 3 files , here they are yourX.key,yourX.csr,yourX.crt .

After finishing the above task add virtualhost within your httpd.conf (or httpd-vhosts.conf on some systems)


<VirtualHost my.localhost:443>
DocumentRoot "/PATH TO YOUR APP/"
ServerName my.localhost
SetEnv APPSTAGE development
<Directory /PATH TO YOUR APP/>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
SSLEngine On
SSLCertificateFile /PATH TO CRT FILE/yourX.crt
SSLCertificateKeyFile /PATH TO KEY FILE/yourX.key
</VirtualHost>

*NOTE: sometimes you may get error like this  "Invalid command 'SSLEngine', perhaps misspelled or defined by a module not included in the server configuration Action 'configtest' failed"
In that case please make sure ssl is enabled ,please run 'a2enmod ssl' to get it working.



Hope it will help you guys :)

-cheers


No comments:

Post a Comment