MAMP local development - cURL error 60: SSL certificate: unable to get local issuer certificate

Viewed 2194

I use MAMP as local development environment. I want to implement a Google Auth - but keep getting this SSL Error.

  1. As other SO topics suggest, I already added this line of code in my PHP.ini file:
curl.cainfo ="C:/MAMP/bin/php/php7.4.1/extras/ssl/cacert.pem"
  1. and added the latest CA certificate from here: https://curl.se/docs/caextract.html in my PHP SSL folder: C:\MAMP\bin\php\php7.4.1\extras\ssl

Any ideea how to pass this SSL error on my local enviroment?

This is the code:

$google_client = new \Google_Client();
    $google_client->setClientId($clientID);
    $google_client->setClientSecret($clientSecret);
    $google_client->setRedirectUri($redirectUri);
    $google_client->addScope("email");
  $google_client->addScope("profile");



    if($this->request->getVar('code')){
        $token = $google_client->fetchAccessTokenWithAuthCode($this->request->getVar('code'));
        if(!isset($token['error'])){
            $google_client->setAccessToken($token['access_token']);
            $this->session->set('access_token', $token['access_token']);

            //get Google profile data
            $google_service = new \Google_Service_Oatuth2($google_client);
            $data = $google_service->userinfo->get();
            print_r($data);

3 Answers

Setting the value for "curl.cainfo" didn't help me. Instead i had to set the value in the "openssl"-section of my current php.ini (Find the current "php.ini"-file in shell with command 'which php'.):

Uncomment and set the openssl.cafile (path is for MacOS):

openssl.cafile="/Applications/MAMP/Library/OpenSSL/certs/cacert.pem"

(Downloaded the pem-file as suggested from https://curl.se/docs/caextract.html )

Update the location of the cacert.pem in your openssl.cnf file to point to the latest version you got from curl.se and you should be right.

The solution described by @tFranz works great! Please note, you can also use your system's cert file instead of MAMP's. This is how I did it:

  1. Find the folder that should contain your cert.pem using this line:
$ openssl version -d
OPENSSLDIR: "/private/etc/ssl"
  1. Open this folder in Finder using:
$ open /private/etc/ssl
  1. Look for a cert.pem file. If you have it, you can add it to your php.ini file:
openssl.cafile="/private/etc/ssl/cert.pem"
Related