dan-coulter / phpflickr

PHP Wrapper for the Flickr API
GNU General Public License v2.0
207 stars 128 forks source link

CURL certification is missing on some server #10

Closed nextend closed 10 years ago

nextend commented 10 years ago

CURL certification is missing on some server. Currently the stable version will give you back false response, but won't give any information about the problem.

My patch contains a feature, which allows you to see the CURL error message if something went wrong also it contains patch for the missing certification.

dan-coulter commented 10 years ago

I'm not going to include this massive certs file just in case someone's curl isn't set up correctly. This seems like an overkill fix.

nextend commented 10 years ago

Thanks, you could also check how Facebook implemented the cacert file. First they create a normal request without the custom cacert and if that fails with specific error codes, then they try again with the cacert file.

https://github.com/facebook/facebook-php-sdk/blob/master/src/base_facebook.php

$result = curl_exec($ch);

$errno = curl_errno($ch);
// CURLE_SSL_CACERT || CURLE_SSL_CACERT_BADFILE
if ($errno == 60 || $errno == 77) {
  self::errorLog('Invalid or no certificate authority found, '.
                 'using bundled information');
  curl_setopt($ch, CURLOPT_CAINFO,
              dirname(__FILE__) . DIRECTORY_SEPARATOR . 'fb_ca_chain_bundle.crt');
  $result = curl_exec($ch);
}