12

I'm trying to run the example that comes with Facebook's PHP SDK, however I'm getting the following error:

Fatal error: Uncaught CurlException: 60: SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed thrown in C:\wamp\www\fb\src\facebook.php on line 614

Any ideas what I'm doing wrong?

Ali
  • 261,656
  • 265
  • 575
  • 769

6 Answers6

24

The problem is cURL has not been configured to trust the server's HTTPS certificate, you can fix that by adding this line of code:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
Rho
  • 1,010
  • 2
  • 11
  • 17
  • 9
    This was very helpful, especially to those testing Facebook apps locally! To make this work, I had to actually add $opts[CURLOPT_SSL_VERIFYPEER] = false; in base_facebook.php around line 935, before curl_setopt_array($ch, $opts); – Bryan Gentry Nov 29 '12 at 01:29
  • @BryanGentry is it advisable to remove that line of code once my site goes into production? – Obay Mar 03 '13 at 03:17
  • I would recommend removing it for live production apps. – Bryan Gentry Mar 03 '13 at 12:33
  • 1
    You probably don't want to disable SSL verification. The root cause is that Facebook updated their SSL certificate and the root isn't available. The [FB SDK on github](https://raw.githubusercontent.com/facebook/facebook-php-sdk/master/src/fb_ca_chain_bundle.crt) contains updated root certificates – TheJosh Jul 24 '14 at 04:47
4

I just had the same problem, and disabling peer verification is not acceptable in my case. I updated the fa_ca_chain_bundle.crt file (from facebook's gitbub) and it works now.

Regards, Marek

Marek Roj
  • 1,221
  • 8
  • 10
3

Raymond Ho answer of adding this line of code works fine:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

Just make sure for the new facebook sdk to have it in the "Facebook_base" file before:

$result = curl_exec($ch);

Thanks.

pouyanghasemi
  • 447
  • 4
  • 8
2

find this line

and immediately following it, add:

$opts[CURLOPT_SSL_VERIFYPEER] = false;

Mitali Mehta
  • 43
  • 1
  • 5
1

other way is add this line, is the same suggestion as the others replies, but in one line, make sure to include the Facebook SDK first

Facebook::$CURL_OPTS[CURLOPT_SSL_VERIFYPEER] = false;
Jose De Gouveia
  • 994
  • 1
  • 14
  • 33
1

I just had the same problem, and you just need to update the crt file that you can find here https://raw.githubusercontent.com/facebook/facebook-php-sdk/master/src/fb_ca_chain_bundle.crt

the crt file is inside the same folder of the file that gives you that error

Robson
  • 916
  • 5
  • 22
  • @ColonelThirtyTwo In this case its an encrypted .crt file that's needed to fix this issue, he can't really share it other than linking to it somewhere externally, and the link he gave is from facebook's official sdk, its unlikely to go down – Ali Aug 05 '14 at 10:38