How to setup HTTPS SSL on WAMP

Web programming topics

How to setup HTTPS SSL on WAMP

Postby Saman » Tue Jun 29, 2010 8:03 pm

Recently I had to run a website with several https links under local server for testing and I had to configure the Open SSL server that comes with WAMP server. I'm sure it would be helpful for you as well.

  1. First thing first, we need to create that self-signed SSL certificate, so go to DOS command prompt (Start menu -> Run -> cmd).

  2. ext, we need to navigate to the directory that contains the openssl executive file which is located in folder C:\wamp\bin\apache\apache2.2.11\bin by default. In order to go there, we need to type the command as follows.
    Code: Select all
    cd\wamp\bin\apache\apache2.2.11\bin


  3. After press Enter, your prompt should change as follows
    Code: Select all
    c:\wamp\bin\apache\apache2.2.11\bin>

    From there, we begin to create the self-signed SSL certificate and the first command you have to type is as follows.
    Code: Select all
    openssl genrsa -aes256 -out pass.key 2048

  4. After press Enter and wait a little while, it should ask you for a pass phrase. Just type in anything but make sure you have to remember that for later use. Of course, it will ask you to verify the pass phrase.
    You may type test123 for testing.

  5. Now, we will create the key for our server. In this tutor guide for HTTPS SSL on WAMP, we will use our domain ExpertCore, but you should use your domain or design name instead.
    Code: Select all
    openssl rsa -in pass.key -out expertcore.key


  6. Next, it will ask you to enter the pass phrase that you have created before. Wait a little while for it to write the key for your server.

  7. Now is the time to type in the command to create our self-signed SSL certificate; since this command is quite long, you will see it takes more than one line, so make sure not to press the Enter key until you finish the whole command.
    Code: Select all
    openssl req -new -x509 -nodes -sha1 -key expertcore.key -out expertcore.crt -days 999 -config C:\wamp\bin\apache\apache2.2.11\conf\openssl.cnf


  8. After press Enter, it will ask you to input 2 letters that presents your country. You can enter LK, US, IN, JP, etc... that represents your country. Next you have to input your State or Province, City, Organization Name, Organization Unit Name, Common Name and Email address.

  9. Guess what, you just got yourself a self-signed SSL certificate. Now, open folder c:\wamp\bin\apache\apache2.2.11\conf and create a new folder "ssl" (without quotes).

  10. Then, from folder c:\wamp\bin\apache\apache2.2.11\bin, copy 2 files key and crt to ssl folder.

  11. Create another folder named as "logs" inside c:\wamp\bin\apache\apache2.2.11\conf\ssl. We save all HTTPS transaction and error logs in this folder.

  12. After that, go to folder c:\wamp\bin\apache\apache2.2.11\conf\extra to open file httpd-ssl.conf.

  13. Find this line:
    Code: Select all
    SSLSessionCache "shmcb:C:/Program Files/Apache Software Foundation/Apache2.2/logs/ssl_scache(512000)"


    Replace with:
    Code: Select all
    SSLSessionCache "shmcb:C:/wamp/bin/Apache/apache2.2.11/conf/ssl/logs/ssl_scache(512000)"


  14. Next find this line:
    Code: Select all
    SSLCertificateFile "C:/Program Files/Apache Software Foundation/Apache2.2/conf/server.crt"


    Remember to substitute expertcore with your domain to replace with:
    Code: Select all
    SSLCertificateFile "C:/wamp/bin/Apache/apache2.2.11/conf/ssl/expertcore.crt"


  15. Then find:
    Code: Select all
    SSLCertificateKeyFile "C:/Program Files/Apache Software Foundation/Apache2.2/conf/server.key"


    Again, substitute expertcore with your domain to replace:
    Code: Select all
    SSLCertificateKeyFile "C:/wamp/bin/Apache/apache2.2.11/conf/ssl/expertcore.key"


  16. Then find:
    Code: Select all
    SSLMutex "file:C:/Program Files/Apache Software Foundation/Apache2.2/conf/ssl/logs/ssl_mutex"


    Replace with:
    Code: Select all
    SSLMutex default


  17. In Virtual Host, find these lines: (ssl34.jpg).
    Code: Select all
    # General setup for the virtual host
    DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs"
    ServerName localhost:443
    ServerAdmin admin@localhost
    ErrorLog "C:/Program Files/Apache Software Foundation/Apache2.2/logs/error_log"
    TransferLog "C:/Program Files/Apache Software Foundation/Apache2.2/logs/access_log"


    HTTPS SSL is the secure transaction which is good for sensitive informations such as Credit card numbers, membership accounts... however, it might slow down your server performances if everything go through it; thus, we suggest that you only set it to the specific directory that you want to use for SSL, and in this example, we use folder ssl:
    Code: Select all
    # General setup for the virtual host
    DocumentRoot "C:/wamp/www/ssl"
    ServerName expertcore:443
    ServerAdmin admin@localhost
    ErrorLog "C:/wamp/bin/Apache/apache2.2.11/conf/ssl/logs/ssl_error.log"
    TransferLog "C:/wamp/bin/Apache/apache2.2.11/conf/ssl/logs/ssl_access.log"


  18. Then find:
    Code: Select all
    <Directory "C:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin">
    SSLOptions +StdEnvVars
    </Directory>


    Modify to become as below:
    Code: Select all
    <Directory "C:/wamp/www/ssl">
    SSLOptions +StdEnvVars
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
    </Directory>


  19. Then find:
    Code: Select all
    CustomLog "C:/Program Files/Apache Software Foundation/Apache2.2/logs/ssl_request_log" \"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"


    And change it as below:
    Code: Select all
    CustomLog "C:/wamp/logs/ssl_request.log" \
        "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"


  20. Next, open file httpd.conf in folder c:\wamp\bin\apache\apache2.2.11\conf and find these lines:

    Code: Select all
    # Secure (SSL/TLS) connections
    #Include conf/extra/httpd-ssl.conf


    Uncomment the second line, and make sure there is no blank space in front of second line and in the end of first line or your wamp will not run:

    Code: Select all
    # Secure (SSL/TLS) connections
    Include conf/extra/httpd-ssl.conf


  21. After save and close all files, left click on WAMP tray icon and navigate to Apache modules and scroll down until you get ssl_module; then, left click on it to enable SSL on WAMP.

  22. Next, navigate to PHP extensions and scroll down until you get php_openssl; then, left click on it to enable open_ssl on WAMP.

  23. Left click on the WAMP tray icon and click on Restart all services.

  24. After that, open folder C:\wamp\bin\apache\apache2.2.11\bin and copy 2 files libeay32.dll and ssleay32.dll and paste them in folder C:\Windows\System32.

  25. Now is the time to test our HTTPS SSL on WAMP, so open your desire text editor and create a simple webpage index.html which is then saved in folder C:\wamp\www\ssl as follows:
    Code: Select all
    <html>
    <
    body>
    <
    font size="5" color="red">test SSL successful</font>
    </
    body>
    </
    html>
     


  26. Now is the time to run the created test file; open your desire browser and input the address bar as below, remember to replace expertcore with your domain or design name:
    Code: Select all
    https://expertcore....


  27. Oops, error... If using Firefox, you can left click on the line "Or you can add an exception...". Again, left click on the button "Add Exception".

  28. On the popup windows, left click on the button "Get Certificate".

  29. You have to left click on the button "Confirm Security Exception".

  30. The moment of success that show up the red line in your browser.
    SSL successful
User avatar
Saman
Support Team
Support Team
 
Posts: 812
Joined: Fri Jul 31, 2009 5:02 pm
Cash on hand: 152,553.20
Location: Mount Lavinia
Medals: 1
EC_Achievment (1)

Invitations sent: 44
Registered friends: 1
Reputation point: 37
Staff Sergeant

Re: How to setup HTTPS SSL on WAMP

Postby notaplayer83 » Tue Jul 20, 2010 8:50 pm

Hi :)

I tried to follow your directions but got this error:

C:\>cd wamp/bin/apache/Apache2.2.11/bin

C:\wamp\bin\apache\Apache2.2.11\bin>openssl genrsa -aes256 -out pass.key 2048
728:error:02001015:system library:fopen:Is a directory:.\crypto\bio\bss_file.c:1
26:fopen('d:/test/openssl098kvc6/openssl.cnf','rb')
728:error:2006D002:BIO routines:BIO_new_file:system lib:.\crypto\bio\bss_file.c:
131:
728:error:0E078002:configuration file routines:DEF_LOAD:system lib:.\crypto\conf
\conf_def.c:199:

I'm using Windows XP, Wampserver 2.0
Thanks in advance for your help
R.
User avatar
notaplayer83
 
Posts: 1
Joined: Tue Jul 20, 2010 8:48 pm
Cash on hand: 134.20

Invitations sent: 0
Registered friends: 0
Reputation point: 0
Lance Corporal

Re: How to setup HTTPS SSL on WAMP

Postby Saman » Wed Jul 21, 2010 7:19 am

That's okay.. just continue to follow next steps.
User avatar
Saman
Support Team
Support Team
 
Posts: 812
Joined: Fri Jul 31, 2009 5:02 pm
Cash on hand: 152,553.20
Location: Mount Lavinia
Medals: 1
EC_Achievment (1)

Invitations sent: 44
Registered friends: 1
Reputation point: 37
Staff Sergeant

Re: How to setup HTTPS SSL on WAMP

Postby Mysoogal » Fri Aug 27, 2010 12:16 am

self-signed certificates why browsers report certificates as suspicious  :cry:
User avatar
Mysoogal
 
Posts: 223
Joined: Thu Dec 17, 2009 1:45 am
Cash on hand: 7,617.70
Location: Planet VPS
Medals: 1
EC_Achievment (1)

Invitations sent: 0
Registered friends: 0
Reputation point: 5
Corporal

Re: How to setup HTTPS SSL on WAMP

Postby naimbic » Thu Dec 02, 2010 4:04 pm

:D Thank you so much for the tutorial it`s perfect...I just couldn`t use it with Google Chrome!! But Firefox Did>>>>
Any other help to get it work with Chrome Please, Thank you :P
Ah other think, to get the website work with https://... it should be in the ssl Folder????
User avatar
naimbic
 
Posts: 1
Joined: Thu Dec 02, 2010 3:58 pm
Cash on hand: 135.50

Invitations sent: 0
Registered friends: 0
Reputation point: 0
Lance Corporal

Re: How to setup HTTPS SSL on WAMP

Postby Pansophic » Tue Mar 01, 2011 9:58 am

you are really awesome man, I am surely gonna try this out.
User avatar
Pansophic
 
Posts: 25
Joined: Sun Feb 13, 2011 10:35 am
Cash on hand: 769.00

Invitations sent: 0
Registered friends: 0
Reputation point: 0
Lance Corporal

Re: How to setup HTTPS SSL on WAMP

Postby mgold » Mon Aug 27, 2012 4:31 pm

:(
when run this command   " openssl rsa -in pass.key -out expertcore.key "
error >>
Warning : can't open config file :/ usr/local/ssl/openssl.cnf

& when run this command  " openssl req -new -x509 -nodes -sha1 -key expertcore.key -out expertcore.crt -days 999 -config C:\wamp\bin\apache\apache2.2.11\conf\openssl.cnf "
Warning : can't open config file :/ usr/local/ssl/openssl.cnf
errore on line -1 of C:\wamp\bin\apache\Apache2.2.21\confopenssl.cnf
2400:error:02001003:system library:fopen:No such process :.\crypto\bio\bss_file.c
.
.
.
Y :( ???
User avatar
mgold
 
Posts: 1
Joined: Mon Aug 27, 2012 4:19 pm
Cash on hand: 134.10

Invitations sent: 0
Registered friends: 0
Reputation point: 0
Lance Corporal

Re: How to setup HTTPS SSL on WAMP

Postby Saman » Tue Aug 28, 2012 8:03 am

Ah other think, to get the website work with https://... it should be in the ssl Folder????

Correct.

when run this command   " openssl rsa -in pass.key -out expertcore.key "
error >>
Warning : can't open config file :/ usr/local/ssl/openssl.cnf
Y :( ???

Looks like you are working on a Linux distribution. Note that this tutorial is for installing HTTPS on WAMP (Windows Apache MySQL PHP) distribution. Please find a guide to install HTTPS on Linux.
User avatar
Saman
Support Team
Support Team
 
Posts: 812
Joined: Fri Jul 31, 2009 5:02 pm
Cash on hand: 152,553.20
Location: Mount Lavinia
Medals: 1
EC_Achievment (1)

Invitations sent: 44
Registered friends: 1
Reputation point: 37
Staff Sergeant


Return to Web programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron