MAMP本地开发-cURL错误60:SSL证书:无法获取本地颁发者证书

Ale*_*ian 5 php ssl curl mamp localhost

我使用 MAMP 作为本地开发环境。我想实施 Google 身份验证 - 但不断收到此 SSL 错误。

  1. 正如其他 SO 主题所建议的那样,我已经在 PHP.ini 文件中添加了这行代码:
curl.cainfo ="C:/MAMP/bin/php/php7.4.1/extras/ssl/cacert.pem"
Run Code Online (Sandbox Code Playgroud)
  1. 并从此处添加了最新的 CA 证书: https: //curl.se/docs/caextract.html在我的 PHP SSL 文件夹中:C:\MAMP\bin\php\php7.4.1\extras\ssl

知道如何在我的本地环境中传递此 SSL 错误吗?

这是代码:

$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);

Run Code Online (Sandbox Code Playgroud)

tim*_*mhj 1

更新 openssl.cnf 文件中 cacert.pem 的位置,使其指向从curl.se 获取的最新版本,您应该是对的。