Invalid or no certificate authority found, using bundled information

匿名 (未验证) 提交于 2019-12-03 02:52:02

问题:

I'm getting started with the facebook API. I downloaded the example code from facebook, configured with my appID and secret keys.

<?php    require '../src/facebook.php';  // Create our Application instance (replace this with your appId and secret). $facebook = new Facebook(array(   'appId'  => '...',   'secret' => '....', ));  // Get User ID $user = $facebook->getUser();  if ($user) {   try {     // Proceed knowing you have a logged in user who's authenticated.     $user_profile = $facebook->api('/me');   } catch (FacebookApiException $e) {     error_log($e);     $user = null;   } }  // Login or logout url will be needed depending on current user state. if ($user) {   $logoutUrl = $facebook->getLogoutUrl(); } else {   $loginUrl = $facebook->getLoginUrl(); }  // This call will always work since we are fetching public data. $naitik = $facebook->api('/naitik');  ?>

on localhost,the script work with no errors. But on host I getting the following error:

Invalid or no certificate authority found, using bundled information

the .crt file was uploaded with success

one may point out my error? thanks in advance.

回答1:

Set the option in CURL to point to your certificate file

This option will tell CURL that your fb_ca_chain_bundle.crt file is in the same folder as your script.

Facebook::$CURL_OPTS[CURLOPT_CAINFO] = getcwd().'/fb_ca_chain_bundle.crt';

In base_facebook.php line 844 curl_exec fails and the error is generated. Then the script sets:

curl_setopt($ch, CURLOPT_CAINFO,               dirname(__FILE__) . '/fb_ca_chain_bundle.crt');

and tries again.

The Second time all is well, there is no problem it just makes a mess of your log

DO NOT use

Facebook::$CURL_OPTS[CURLOPT_SSL_VERIFYPEER] = false;

Or a man-in-middle will be able to intercept your call!



回答2:

Disable the SSL security feature

Though I don't recognize that exact error message, SSL problems when communicating with Facebook via the PHP SDK (and thus Curl) are common. Have you tried doing something like this?

Facebook::$CURL_OPTS[CURLOPT_SSL_VERIFYPEER] = false;

This will disable the SSL "Verify Peer" security feature so that it stops generating the error message.



回答3:

get the latest plugin from http://wordpress.org/extend/plugins/facebook-feed-grabber/ and replace the old chain certificate with new one



回答4:

I've checked the server config and everything seems fine. However I've seen a few other posts on the internet where users have fixed the issue by editing the following lines in

"base_facebook.php"

/** * Default options for curl. */

public static $CURL_OPTS = array( CURLOPT_CONNECTTIMEOUT => 10, CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 60, CURLOPT_USERAGENT => 'facebook-php-3.2', CURLOPT_SSL_VERIFYPEER => false, (ADDED THIS LINE) );

I've tested it and this now works, and it successfully posts to the Facebook page.

Cheers!

Mudassar Ali



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!