I try to make a cURL Authentication, but I have problems with the SSL certificates.
I have this code:
$username = "123";
$password = "123";
$host = "https://api.shipnow.com.ar/users/authentication";
$headers = array(
'Content-Type:application/json',
'Authorization: Basic '. base64_encode("$username:$password") // <---
);
$process = curl_init($host);
curl_setopt($process, CURLOPT_HTTPHEADER, $headers);
curl_setopt($process, CURLOPT_HEADER, 1);
curl_setopt($process, CURLOPT_TIMEOUT, 30);
curl_setopt($process, CURLOPT_POST, 1);
curl_setopt($process, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($process, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($process, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($process, CURLOPT_CAINFO, '/cacert.pem');
curl_setopt($process, CURLOPT_CAPATH, '/cacert.pem');
$return = curl_exec($process);
$error = curl_error($process);
curl_close($process);
var_dump($error);
But return me this:
error setting certificate verify locations: CAfile: /cacert.pem CApath: /cacert.pem
I download the cacert.pem from this link:
https://curl.haxx.se/docs/caextract.html
And I put it in my project folder, next to index.php
Anyone knows how to solve the problem?
Regards,