"SSL certificate problem: unable to get local issuer certificate" in an API request via Curl / PHP.

andre_moraes July 6, 2020

function get_from($resource, $data) {
$jdata = json_encode($data);
$ch = curl_init();
//configure CURL
curl_setopt_array($ch, array(
CURLOPT_URL => 'https://mydomain.atlassian.net/rest/api/2/project',
CURLOPT_USERPWD => '<user>' . ':' . '<password>',
CURLOPT_POSTFIELDS => $jdata,
CURLOPT_HTTPHEADER => array('Content-type: application/json'),
CURLOPT_RETURNTRANSFER => true
));
$result = curl_exec($ch);
echo "<br>";
echo curl_errno($ch);
echo "<br>";
echo curl_error($ch);
echo "<br>";
curl_close($ch);

return json_decode($result);
}

2 answers

0 votes
9uilhermealencar December 26, 2022

Check if you have a certificate like *.atlassian.net in your keychain tool. 

If you don't have it, go to your browser and open yourdomain.atlassian.net, then click on the padlock and export the certificate(1). Open it in you keychain tool and set it to always trust.

Retry the call and see if it works.

(1) Click on the padlock > Certificate is secure > Certificate is valid > Details > Export

0 votes
Daniel Eads
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 29, 2020

Hi Andre, welcome to the Community!

I'm interested in knowing a bit more about the environment you're trying to run this function on.

  • What's the operating system and version?
  • Are there any potential forward proxies between this box and the internet that might be trying to intercept the SSL connection?

You could try verifying that openssl sees an Atlassian-signed certificate for the URL you're trying to connect to:

openssl s_client -connect yourdomain.atlassian.net:443

This command will also print the intermediate certs used in the chain, which will need to be in your system's trust store. DigiCert certificates should be for nearly any operating system you could be using, but one possibility might be that you've encountered a VM image that has had its certificate stores removed.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events