Help: Uncaught exception 'apiIOException' with message 'HTTP Error: (60) SSL certificate problem, verify that the CA cert is OK

4,926 views
Skip to first unread message

Debarshi Banerjee

unread,
Sep 9, 2011, 4:39:54 AM9/9/11
to google-api...@googlegroups.com
hi,

i quite do not understand what is going on:

every time i am trying to authenticate i am getting this error:

Fatal error: Uncaught exception 'apiIOException' with message 'HTTP Error: (60) SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed' in C:\xampp\htdocs\google-api-php-client\src\io\apiCurlIO.php:120 Stack trace: #0 C:\xampp\htdocs\google-api-php-client\src\auth\apiOAuth2.php(60): apiCurlIO->makeRequest(Object(apiHttpRequest)) #1 C:\xampp\htdocs\google-api-php-client\src\apiClient.php(121): apiOAuth2->authenticate(Array) #2 C:\xampp\htdocs\google-api-php-client\examples\urlshortener\index.php(39): apiClient->authenticate() #3 {main} thrown in C:\xampp\htdocs\google-api-php-client\src\io\apiCurlIO.php on line 120

i am using the example that came with google api php client for urlshortener! I have generated and put the client id, client secret and redirect url.. my code goes as follows

session_start();

require_once '../../src/apiClient.php';
require_once '../../src/contrib/apiUrlshortenerService.php';

global $apiConfig;

$apiConfig['oauth2_client_id'] = 'my client id';
$apiConfig['oauth2_client_secret'] ='my client secret';
$apiConfig['authClass'] = 'apiOAuth2';
$client = new apiClient();
$service = new apiUrlshortenerService($client);

if (isset($_REQUEST['logout'])) {
  unset($_SESSION['access_token']);
  header('Location: http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);
}

if (isset($_GET['code'])) {
  $client->authenticate();
  $_SESSION['access_token'] = $client->getAccessToken();
  header('Location: http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);
}

if (isset($_SESSION['access_token']) && $_SESSION['access_token']) {
  $client->setAccessToken($_SESSION['access_token']);
} else {
  $authUrl = $client->createAuthUrl();
}

if ($client->getAccessToken() && isset($_POST['url'])) {
  // Start to make API requests.
  $url = new Url();
  $url->longUrl = $_POST['url'];
  $short = $service->url->insert($url);
  $_SESSION['access_token'] = $client->getAccessToken();
}
?>
<!doctype html>
<html>
<head><link rel='stylesheet' href='style.css' /></head>
<body>
<header><h1>Google Url Shortener Sample App</h1></header>
<div class="box">
  <div class="request">
    <?php if (isset($authUrl)): ?>
      <a class='login' href='<?php print $authUrl; ?>'>Connect Me!</a>
    <?php else: ?>
      <form id="url" method="GET" action="index.php">
        <input name="url" class="url" type="text">
        <input type="submit" value="Shorten">
      </form>
      <a class='logout' href='?logout'>Logout</a>
    <?php endif ?>
  </div>

  <?php if (isset($short)): ?>
    <div class="shortened">
      <pre><?php var_dump($short); ?></pre>
    </div>
  <?php endif ?>
</div>
</body></html>




Chirag Shah

unread,
Sep 9, 2011, 12:29:56 PM9/9/11
to google-api...@googlegroups.com
It looks like your server is unable to perform peer SSL certificate
verification. Which version of curl and php do you have installed on
your system?

You can determine this by running the following commands:
curl --version
php --version

Debarshi Banerjee

unread,
Sep 12, 2011, 9:16:17 AM9/12/11
to google-api...@googlegroups.com
I am using a xampp architecture on windows 7 64 bit. My curl version is 7.19.6 and my php version is 5.3.1 and my SSL Version - OpenSSL/0.9.8l

Chirag Shah

unread,
Sep 12, 2011, 2:32:25 PM9/12/11
to google-api...@googlegroups.com
Ah, this is windows version of PHP and it doesn't come bundled with a Certificate Authority bundle.

You need to add the following line to apiCurlIO.php right before the line "$data = @curl_exec($ch);"
curl_setopt($ch, CURLOPT_CAINFO, 'c:/path/to/ca-bundle.crt');

You'll need to replace 'c:/path/to/ca-bundle.crt' to whereever you have the ca-bundle.crt file.

Here's a good article explaining what's going on in the windows version of PHP.

Debarshi Banerjee

unread,
Sep 13, 2011, 12:40:00 AM9/13/11
to google-api...@googlegroups.com
Hi Chriag,

Thank you, thank you! it worked like magic. I did not know about this before because all the deployment servers i have worked with is linux.

One more thing i want to point out, in the index.php of examples\urlshortener there is a small problem :- I have highlighted it in bold

if ($client->getAccessToken() && isset($_POST['url'])) {
  // Start to make API requests.
  $url = new Url();
  $url->longUrl = $_POST['url'];
  $short = $service->url->insert($url);
  $_SESSION['access_token'] = $client->getAccessToken();
}
...................
<form id="url" method="GET" action="index.php">   //this should be method="POST"
        <input name="url" class="url" type="text">
        <input type="submit" value="Shorten">
      </form>

...................

Once you change the method to POST it works amazingly!

regards,
Debarshi

Chirag Shah

unread,
Sep 13, 2011, 1:30:27 AM9/13/11
to google-api...@googlegroups.com
Great! I'm glad to hear that it worked for you. The bug in
examples/urlshortener was fixed earlier today and included in the
google-api-php-client-0.4.2 release.


Thanks!
Chirag Shah

neelesh vishwakarma

unread,
Jan 19, 2012, 12:51:39 AM1/19/12
to google-api...@googlegroups.com
Thanks Chirag Shah..
I was facing the same issue.. But as I added crt file ,Its start working for me... Many thanks...

Jeffrey Gould

unread,
Feb 13, 2012, 5:05:07 PM2/13/12
to google-api...@googlegroups.com
Hello, I am experiencing this same problem using a MAMP environment in OSX - I looked to see if this was a patch I could make to my api files but it looks like maybe I've got a newer version as this line isn't even in apiCurlIO.php . 


and here is the specific error I'm getting: 

Fatal error: Uncaught exception 'apiIOException' with message 'HTTP Error: (0) SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed' in /Users/jrgweb/Sites/oauthTest/google_api/src/io/apiCurlIO.php:119 Stack trace: #0 /Users/jrgweb/Sites/oauthTest/google_api/src/auth/apiOAuth2.php(93): apiCurlIO->makeRequest(Object(apiHttpRequest)) #1 /Users/jrgweb/Sites/oauthTest/google_api/src/apiClient.php(138): apiOAuth2->authenticate(Array) #2 /Users/jrgweb/Sites/oauthTest/test.php(25): apiClient->authenticate() #3 {main} thrown in /Users/jrgweb/Sites/oauthTest/google_api/src/io/apiCurlIO.php on line 119

Thanks in advance for any help. 

Chirag Shah

unread,
Feb 13, 2012, 11:45:48 PM2/13/12
to google-api...@googlegroups.com
On Mon, Feb 13, 2012 at 2:05 PM, Jeffrey Gould <jrg...@gmail.com> wrote:
Hello, I am experiencing this same problem using a MAMP environment in OSX - I looked to see if this was a patch I could make to my api files but it looks like maybe I've got a newer version as this line isn't even in apiCurlIO.php . 


and here is the specific error I'm getting: 

Fatal error: Uncaught exception 'apiIOException' with message 'HTTP Error: (0) SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed' in /Users/jrgweb/Sites/oauthTest/
Hey Jeffery,

This error means curl was unable to find a certificate bundle on your system for validating SSL connections.  Since this is a frequent issue for PHP deployments, the latest version of the PHP client (on trunk) contains its own bundle for validating SSL connections when making API requests.

Simply grab the latest version of the client on trunk and things should just work:

Thanks!
Chirag
Message has been deleted

Chirag Shah

unread,
Mar 4, 2012, 5:53:52 PM3/4/12
to google-api...@googlegroups.com
Hey Johnny,

Sorry about that. The fix for this is currently available on trunk (it is being tested and stabilized) and hasn't been released yet.

You can grab the latest version by running the command:
svn checkout http://google-api-php-client.googlecode.com/svn/trunk/ google-api-php-client-read-only

Another option is to wait for the google-api-php-client-0.5.0 release build.

I hope this helped!
Chirag


On Sat, Mar 3, 2012 at 2:07 PM, Johnny Ho <johanne...@gmx.de> wrote:
Hey,

I am having the same issue as Chirag and couldn't really follow your instructions on how to solve it. Could you please explain them in more details?

Thanks in advance.

Muhammad Ghasan

unread,
Jan 3, 2013, 6:12:15 PM1/3/13
to google-api...@googlegroups.com
hi Chirag Shah.
I am new to g+api and tried to follow this step you listed.

"You need to add the following line to apiCurlIO.php right before the line "$data = @curl_exec($ch);"
curl_setopt($ch, CURLOPT_CAINFO, 'c:/path/to/ca-bundle.crt');" but unable to find ca-bundle.crt. Can you please help me.

Thanks

Debarshi Banerjee

unread,
Jan 4, 2013, 1:17:03 AM1/4/13
to google-api...@googlegroups.com
Hi Muhammad,

Check this site out it will help you,

Also to download the necessary files directly:

regards,
Debarshi.

Seto El Kahfi

unread,
Mar 13, 2013, 5:32:53 AM3/13/13
to google-api...@googlegroups.com
Thank you very much, I'm facing the same problem too :)

Zuber Doshani

unread,
Sep 29, 2013, 8:17:35 AM9/29/13
to google-api...@googlegroups.com
Sir i cant find apicurllO.php. i m using google analytics plugin and have error about certificate authority bundle. please please help
Reply all
Reply to author
Forward
0 new messages