0

I have deployed my site and its working perfectly with all functionalities. This is a e-commerce site. So for further developments I have downloaded the files from the hosting server and everything working fine. In this site I add products as below

  • Add a new product to the system.(working on both local machine and online site)

  • Then this relevant product will be assigned into a certain list which exist in the system. (working well on online site but generate below error in local server.)

Error connecting to CommissionJunction Token : [60] SSL certificate problem: unable to get local issuer certificate

System specification

  • framework - Laravel 5.3
  • Local machine os - Windows 10
  • Local machine web serve - WAMP
  • php version - 7.1.9

As I said before this function is working perfectly online. But it generate mentioned error in local machine

I have googled this and unable to find any solution.

Also navigated through below stackoverflow questions already

  1. curl: (60) SSL certificate : unable to get local issuer certificate
  2. PayPal IPN: unable to get local issuer certificate
  3. SSL errors using MailChimp's API
  4. How do you add a certificate authority (CA) to Ubuntu?

Also went through this too cURL on Windows

Laravel shows that error occoured in this line . But I think that there is no coding error.

 $body = curl_exec($ch);
    $errno = curl_errno($ch);
    if ($errno !== 0) {
        throw new Exception(sprintf("Error connecting to CommissionJunction Token : [%s] %s", $errno, curl_error($ch)), $errno);
    }

After going through all these still no luck . So any help on this will be warmly welcomed. Thanks.

Update 01

Acorrding to the comments I have changed below changes

  • Downloaded the latest certificate bundle via CA certificates extracted from Mozilla
  • Then certificate bundle moved to c:\wamp64\
  • Enabled mod_ssl in Apache as below (I'm not sure ether this method is OK or not)
  • Clicked on the WAMP icon -> Apache 2.4.27 -> Apache modules -> then select the ssl_module
  • Enabled the php_openssl.dll in php.ini by removing ;
  • Added below codes to php.ini
    • curl.cainfo="C:/wamp64/cacert.pem"
    • openssl.cafile="C:/wamp64/cacert.pem"
  • Restarted the serve
Nipun Tharuksha
  • 2,496
  • 4
  • 17
  • 40
  • Did you attach the local issuer certificate? You can find the path to the cert in php.ini with mostly the key as `openssl.cafile = "..."` or something along those lines. – nice_dev Aug 16 '19 at 13:40
  • @Nipun Tharuksha Try this: https://stackoverflow.com/questions/28858351/php-ssl-certificate-error-unable-to-get-local-issuer-certificate?rq=1, That helped me a lot – Serghei Leonenco Aug 16 '19 at 13:42
  • @SergheiLeonenco can you please tell me how to Enable mod_ssl in Apache – Nipun Tharuksha Aug 16 '19 at 14:00
  • @vivek_23 I have added these to lines to `php.ini` `curl.cainfo="C:/wamp/cacert.pem"` `openssl.cafile="C:/wamp/cacert.pem"` – Nipun Tharuksha Aug 16 '19 at 14:01
  • @Nipun Tharuksha Try this: https://stackoverflow.com/questions/5257974/how-to-install-mod-ssl-for-apache-httpd Hope it helps – Serghei Leonenco Aug 16 '19 at 14:10
  • For local testing only you could try to set: `curl_setopt($cHandler, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($cHandler, CURLOPT_SSL_VERIFYPEER, false);` Never do this on production! – schlicki Aug 20 '19 at 10:05
  • @schlicki thanks for commenting. Could you please explain bit more. Thanks – Nipun Tharuksha Aug 20 '19 at 10:59
  • 1
    verifyhost checks if the name of the certificate matches the host's name. verifypeer checks if the certificate is valid (trusted ca, complete chain, etc.). this is just for narrowing down the errors. – schlicki Aug 21 '19 at 11:19

1 Answers1

2

Follow the below steps to work curl on wamp

Note: wamp server having multiple version of php so changes need to made in all php.in files

Step 1: Download the certificate bundle. Copy to C:/wamp64/

Step 2: Open php.ini by clicking wamp icon in notification bar also open version specific php.ini file through directory ie "E:\wamp\bin\php\php7.1.22".

Step 3: Remove ; before ;extension=php_openssl.dll (ignore if already removed)

Step 4: Find [curl] in php.ini then add below curl.cainfo="C:/wamp64/cacert.pem"

Step 5: Find [openssl] in php.ini then add below openssl.cafile="E:\wamp\cacert.pem"

step 6: Reastart wamp

Sharad Kale
  • 971
  • 1
  • 7
  • 19