Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
297 views
in Technique[技术] by (71.8m points)

google api - any idea of how curl cacert broke my php app?

------Answer below--------

I know many post already talk about this but I've tried everything and I think nothing worked.

I use Google API for connection to a website and after to manage Google drive with API and Google library in PHP.

Pretty simple, I've got an issue with curl error 60, so I've checked curl.se website to get the last cacert.pem.

for those who would have my code, in my connection module, if i delete the verify line :

$client = new Client([
    'timeout' => 2.0,
    'verify' => __DIR__ . '/cacert.pem'
]);

i got this :

cURL error 60: SSL certificate problem: unable to get local issuer certificate

If i keep the verify, it work. And my drive manager module :

$client = new Google_Client([
'timeout' => 2.0,
'verify' => __DIR__ . '/cacert.pem'
]);
$client->useApplicationDefaultCredentials();
$client->addScope(Google_Service_Drive::DRIVE);
$driveManager = new Google_Service_Drive($client);

$client->setSubject('[email protected]');

// Print the names and IDs for up to 10 files.
$optParams = array(

    'fields' => 'nextPageToken, files( name)',
    'q' => 'folder',
);

$results = $driveManager->files->listFiles($optParams);"

Of course there is require vendor/autoload and putenv blablabla to open my credentials json file before and the printf foreach $results under..

The thing is, with the same cacert.pem verification, since the last update of cacert.pem on curl.se website (aka the 19/01/2021), this module doesn't work at all with the same error!

I'm a new user with Google API and I don't understand everything.

question from:https://stackoverflow.com/questions/65831578/any-idea-of-how-curl-cacert-broke-my-php-app

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

i've finally hosted my app today, to get it online, and it seems to work.

As my host use ssl by let's encrypt, my app dont use the cacert.pem as scpecified just above in the post, but it use the main certificate of my website, which is my host certificate.

When i've tested it, the error seems appear when the app request to : https://oauth2.googleapis.com/token, and it appear just when i've updated to the last cacert.pem file, so i guess there is an error somewhere that is not made by my hand...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...