Troubleshooting: PHP API for Cloud Files Stops at Authentication

March 23, 2009 · 9 comments

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.


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


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 comments… read them below or add one }

Rob Evans February 7, 2013 at 8:35 am

Thanks that did the trick:

apt-get install ca-certificates


Justin Carmony 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.


randulo 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 “”
ln cacert.pem curl-ca-bundle.crt


Sky 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.


Mike October 17, 2009 at 4:27 pm

Turns out although the CA import worked, cURL doesn’t recognize the new certificates :-(


Mike 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.


Andrew 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!


omprakash 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


Phil April 9, 2009 at 10:58 pm

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



Leave a Comment

Previous post:

Next post: