Skip to content
Jon's View

Jon's View

a technology blog by Jon Stacey

Menu
  • Contact
Menu

Troubleshooting: PHP API for Cloud Files Stops at Authentication

Posted on March 23, 2009January 24, 2010 by Jon Stacey

The PHP API for Cloud Files does not catch CURL errors. An exception will be thrown, however it will not contain any useful information to troubleshoot the problem. Here is a likely symptom and a solution.

Symptoms

You may notice messages in the stack trace about being unable to authenticate, but no reason as to why. For example, using the WordPress CDN Tools plugin, the error message might look like the following:

Fatal error: Uncaught exception 'InvalidResponseException' with message 'Unexpected response (): ' in

Solution

The problem that I ran into was missing CA certificates. It was resolved by running the following command on my Ubuntu box:

sudo aptitude install ca-certificates

An alternative is to ignore certificates altogether, which from a security standpoint is not very wise. But if you are desperate, add the following to cloudfiles_http.php line 210 (as of the time of this writing, the current version is 1.3.0). There should be a block of curl_setopt() commands. Add the command before the curl_exec().

curl_setopt($curl_ch, CURLOPT_SSL_VERIFYPEER, false);

If that fails and the exception messages are not telling you what the problem is, it could be something different altogether. In this worst case scenario, place the following line just after the curl_exec() but before curl_close().

print curl_error($curl_ch);

That should then give you the necessary information to correct the problem.

Good luck and feel free to post a comment if you discover different problems or solutions to the PHP API for Cloud Files.

9 thoughts on “Troubleshooting: PHP API for Cloud Files Stops at Authentication”

  1. Rob Evans says:
    February 7, 2013 at 8:35 am

    Thanks that did the trick:

    apt-get install ca-certificates

    Reply
  2. Justin Carmony says:
    April 11, 2011 at 4:34 pm

    Thanks! This helped a lot. Was starting to tear out my hair not knowing why one server was working while the other failed.

    Reply
  3. randulo says:
    April 24, 2010 at 4:39 am

    After checking all the SSL and cURL stuff, it was all right. Downloading the cert and renaming it did the trick for us:

    cd /usr/local/share
    mkdir curl
    cd curl
    wget “http://curl.haxx.se/docs/caextract.html”
    ln cacert.pem curl-ca-bundle.crt

    Reply
  4. Sky says:
    January 2, 2010 at 7:52 pm

    Installing ca-certificates solved my issue. Thanks a lot for documenting this, saved me a lot of time.

    Reply
  5. Mike says:
    October 17, 2009 at 4:27 pm

    Turns out although the CA import worked, cURL doesn’t recognize the new certificates 🙁

    Reply
  6. Mike says:
    October 17, 2009 at 4:01 pm

    You can import the CA bundle if you’re running Mac OS X by opening Keychain Access, then clicking on the ‘System’ keychain, then click File > Import Items… and choose the cacert.pem file.

    Reply
  7. Andrew says:
    September 15, 2009 at 5:15 pm

    Excellent. I’m glad I found this as when I first installed the API it threw the same error. It looks like it was updated to allow alternate CAs – this is in the documentation:
    ($auth->ssl_use_cabundle(); # bypass cURL’s old CA bundle)

    But when I put that in, it still didn’t work. Doing an aptitude install did the trick. Thanks!

    Reply
    1. omprakash says:
      June 21, 2011 at 1:31 am

      Hi Andrew

      I am also getting this error and i tried the second option changes cloudfiles_http.php but it still not working. I need help: how to install the ca certificate on my linux server. And also tell me how to remove or uninstall if it causes problem

      Reply
  8. Phil says:
    April 9, 2009 at 10:58 pm

    This is great – thanks for the detailed writeup – saved me some time for sure.

    -Phil

    Reply

Leave a Reply to Justin Carmony Cancel reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

©2025 Jon's View | Built using WordPress and Responsive Blogily theme by Superb