Install SSL Certificate On wamps server (localhost)

How to enable SSl on Wamp Server(apache2) - HTTPS Configuration

In this article, I will show how to Configure/Enable SSL in Wamp Server.I have installed wampserver with apache 2.2.12 and php 5.3.5. I have to configure the Open SSL server.
How to Setup HTTPS SSL on WAMP Server for apache 2.2

1. Install WAMPServer
2. Open Control Panel
3. Click System >> Select Advanced System Setting >> Select Environment Variables.
4.Create new system variable OPENSSL_CONF:
Value: C:\wamp\bin\apache\apache2.2.12\conf\openssl.cnf

5. Create a SSL Certificate and Key for the Web Server
Open command prompt and Run the following commands:

>cd wamp\bin\apache\apache2.2.12\bin
>openssl genrsa -des3 -out server.key 1024
>copy server.key server.key.org
>openssl rsa -in server.key.org -out server.key
>openssl req -new -x509 -nodes -sha1 -days 365 -key server.key -out server.crt -config C:\wamp\bin\apache\apache2.2.12\conf\openssl.cnf

Create a folder c:\wamp\OpenSSL with the following subfolders:
i. certificats
ii. private

Copy server.cert, server.csr, server.key files

from C:\wamp\bin\apache\Apache2.2.12\bin to C:\wamp\OpenSSL\certificats folder

Copy server.key.org file from

C:\wamp\bin\apache\Apache2.2.12\bin to C:\wamp\OpenSSL\private folder

6. Open Php.ini file

Remove comment of following line:
extension=php_openssl.dll

OR

Left click the wampserver icon >> PHP >> php extensions >> click php_openssl

7. Open Httpd.conf file (C:\wamp\bin\apache\Apache2.2.12\conf\)

Remove comment of following lines:

LoadModule ssl_module modules/mod_ssl.so
LoadModule setenvif_module modules/mod_setenvif.so
Include conf/extra/httpd_ssl.conf

8.Open httpd-ssl.conf file(C:\wamp\bin\apache\Apache2.2.12\conf\extra\)

Find and replace follwing lines:

SSLMutex default

DocumentRoot "C:/wamp/www"
ErrorLog "C:/wamp/logs/ssl_ErrorLog.txt"
TransferLog "C:/wamp/logs/ssl_TransferLog.txt"
SSLCertificateFile "C:/wamp/OpenSSL/certificats/server.crt"
SSLCertificateKeyFile "C:/wamp/OpenSSL/certificats/server.key"
CustomLog "C:/wamp/logs/ssl_request.txt" \
"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
Change Directory Tag:
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all

9.Verify SSL/HTTPS

•Run httpd –t and make sure the syntax is OK.

•Restart Apache.

10.Check whether the WAMP server is running or not

Right click the wampserver icon >> Rsstart All Services
•If icon is partially red, it means no service is currently running
•If icon is White, that means all services are running.

11.Open https://localhost
12.Done.

I hope this article will help you to enable SSL on the Apache server.

Ohh Missed below Conf..

Found a solution:

Here are the instructions how to get rid of the SSLSessionCache message in XAMPP

1) Open file \xampp\apache\conf\httpd.conf

2) Somewhere in the LoadModule area add the following line:

LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
3) Save the file

4) Now open file \xampp\apache\conf\extra\httpd-ssl.conf

5) at line 70 add the line

SSLSessionCache "shmcb:logs/ssl_scache(512000)"
6) Save the file

7) Restart Apache

curl in php (How to set the authorization header using curl)




$service_url = 'https://example.com/something/something.json';
$curl = curl_init($service_url);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_USERPWD, "username:password"); //Your credentials goes here
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $curl_post_data);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

 //IMP if the url has https and you don't want to verify source certificate

$curl_response = curl_exec($curl);
$response = json_decode($curl_response);
curl_close($curl);

var_dump($response);

Log file snippets in php

        $log_string = 'done';
$file_name  = '/var/log/logfilename.log';
$handle = fopen ( $file_name, 'a+' );
if ($handle) {
fwrite ( $handle, date ( 'Y-m-d H:i:s' ) . '  ' . $log_string . "\n" );
fclose ( $handle );
        }