Twilio PHP - SSL certificate: self signed certificate in certificate chain

jd182 picture jd182 · Mar 19, 2015 · Viewed 21k times · Source

I'm struggling with this error when trying to send a message via Twilio using their PHP library:

Fatal error: Uncaught exception Services_Twilio_TinyHttpException with message SSL certificate problem: self signed certificate in certificate chain thrown in F:\path\to\site\twilio-php\Services\Twilio\TinyHttp.php on line 119

I'm using wamp on windows 7.

I have of course found all of the other posts about certificate errors. From what I can see, usually updating or adding the cacert.pem file fixes the issue. However, even after doing this i'm still getting the same error.

Just as a sanity check here is exactly what i've done:

  1. Downloaded the latest certificates from here: http://curl.haxx.se/ca/cacert.pem.
  2. Placed this file in the following location c:/wamp/certs/cacert.pem
  3. Updated php.ini as follows: curl.cainfo = c:/wamp/certs/cacert.pem
  4. Restarted all wamp services including apache

And i'm still getting the same error. I have verified that I am editing the correct php.ini using phpinfo(). I'm at a loss as to why it's still complaining.

Is there any way to verify 100% that my cacert.pem file is being found and read? I've checked phpinfo() and there is no mention of it in there. Should it say somewhere which, if any cacert.pem it's using?

Thanks!

Answer

codemonkey picture codemonkey · Jul 8, 2015

I had the exact same issue

Follow these steps:

Download the following file - cacert.pem

Then download the following file - thawte_Premium_Server_CA.pem

Open the second file in a text editor and copy its contents into the first file (cacert.pem at the bottom/end).

Save cacert.pem and add the following lines to your php.ini :

[curl]
curl.cainfo=c:/xampp/php/cacert.pem

Obviously change the directory to the one where your pem is located. Restart the php local server (xampp/wamp). Then it will work flawlessly.

thanks.