[API] SSL certificate problem, verify that the CA cert is OK

Hello, I’m writting a small script to regularily check if a single stream is online or not using PHP. I’m getting an error with the SSL certificate:

SSL certificate problem, verify that the CA cert is OK. Details:

error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

And this is the PHP code:

<?php
$ch = curl_init('https://api.twitch.tv/kraken/streams/pnoexz');
curl_setopt($ch,CURLOPT_HTTPHEADER,array('Accept: application/vnd.twitchtv.v3+json'));
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
$t = curl_exec($ch);

var_dump($t);
var_dump(curl_error($ch));

This is using fairly recent versions of both PHP and cURL. I found a workaround for this while making this topic, but I feel like a proper fix should be issued. The workaround is turning off the verification of the certificate (which renders forcing HTTPS rather useless) using the option CURLOPT_SSL_VERIFYPEER to false:

curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);

The SSL in use by Twitch is fine, but your server’s configuration needs work.

Usually this is simply resolved by installing the CA certificates on your host. If you’re using Debian as your server OS, this is simple to do:

sudo apt-get install ca-certificates