SSL error with PHP curl
api, curl, php, ssl
Solution
After having made sure that your certificate bundle is readable by the script you're running, the next step is to investigate the server itself.
If this is your own server, it's likely that you forgot to install the intermediate certificates, i.e. the ones in between the issued certificate and one of the certificate authorities that comes with the bundle.
If you're working with a self-signed certificate, your `cacert.pem` should contain the public certificate of the server you're connecting to; this can be generated from the private certificate, outlined here, referred to as the `.crt` file.
Problem
Hello fellow programmers, I'm making an API with a https connection. I want to secure the API call with a certificate check. Now i've downloaded the cacert.pem from curl and placed this in my folder, but it doesn't work and gives me this error: ``` SSL certificate problem: unable to get local issuer certificate ``` Well i'm really sure that the cacert.pem file is located correctly but for you guys some code that i've been writing to get it working: ``` $ch = curl_init($url); curl_setopt($ch, CURLOPT_POST ,1); curl_setopt($ch, CURLOPT_USERPWD, $this->api_key . ":" . $this->api_secret); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1); curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . "/cacert.pem"); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($ch, CURLOPT_POSTFIELDS ,$post_vars); curl_setopt($ch, CURLOPT_FOLLOWLOCATION ,0); curl_setopt($ch,CURLOPT_HTTPHEADER,array('Accept: application/json')); curl_setopt($ch, CURLOPT_RETURNTRANSFER ,1); // RETURN THE CONTENTS OF THE CALL $data = curl_exec($ch); ``` I hope you some of you guys have an answer for my question because I really don't know much about SSL connections. Thanks in advance!