SSL problem only when reporting

172 views
Skip to first unread message

Joaquín

unread,
Jan 29, 2018, 1:17:04 AM1/29/18
to AdWords API Forum

Hi!!

I've sucessfully executed sample examples provided in PHP API.

In my localhost Windows environment I just overrided SSL validation setting it to false (I know it's not recommeded). I also had to manually specify clientCustomerId because the value specified in the .ini file was not taken into account.

      $soapSettings = (new SoapSettingsBuilder())
      ->disableSslVerify()
      ->build();

      $session = (new AdWordsSessionBuilder())
      ->fromFile()
      ->withSoapSettings($soapSettings)
      ->withOAuth2Credential($oAuth2Credential)
      ->withClientCustomerId("123-456-7890")
      ->build();


Sample GetCampaings.php  or GetReportFields worked like a charm.

The problem arises when executing sample DownloadCriteriaReportWithSelector. Again there are problems with SSL validation.

Looks like the http calls made with Guzzle does not take into account  the disableSslVerify() in SoapSettings. When executing I get this error.

PHP Fatal error:  Uncaught exception 'RuntimeException' with message 'Error creating resource: [message] fopen(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed
[file] E:\xampp\htdocs\apiadwords\vendor\guzzlehttp\guzzle\src\Handler\StreamHandler.php
[line] 329
[message] fopen(): Failed to enable crypto
[file] E:\xampp\htdocs\apiadwords\vendor\guzzlehttp\guzzle\src\Handler\StreamHandler.php
[line] 329
[message] fopen(https://adwords.google.com/api/adwords/reportdownload/v201710): failed to open stream: operation failed
[file] E:\xampp\htdocs\apiadwords\vendor\guzzlehttp\guzzle\src\Handler\StreamHandler.php
[line] 329' in E:\xampp\htdocs\apiadwords\vendor\guzzlehttp\guzzle\src\Handler\StreamHandler.php:252
Stack trace:
#0 E:\xampp\htdocs\apiadwords\vendor\guzzlehttp\guzzle\src\Handler\StreamHandler.php(341): GuzzleHttp\Handler\StreamHandler->createResource(Object(Closure))
#1 E:\xampp\htdocs\apiadwords\vendor\guzzlehttp\guzzle\sr in E:\xampp\htdocs\apiadwords\vendor\guzzlehttp\guzzle\src\Exception\RequestException.php on line 52

I just "solved it" (not a solution I know) by hacking Guzzle's StreamHandler and forcing enable SSL validation to false.

        // Ensure SSL is verified by default
        if (!isset($options['verify'])) {
            $options['verify'] = false;
        }
        
        // Horrible hack to not to do
        $options['verify'] = false;

How could I solve this in a more appropiate way?
Thanks a lot !!!!

Vincent Racaza (AdWords API Team)

unread,
Jan 29, 2018, 2:51:35 AM1/29/18
to AdWords API Forum
Hi,

The SSL error (Certificate verify failed) is due to an issue in the application's network layer. Since this is more on the PHP client library, and not the AdWords API itself, then I suggest to post this in the PHP client library as the library owner can better provide assistance regarding this.

Thanks,
Vincent
AdWords API Team

Joaquín

unread,
Jan 29, 2018, 9:47:58 AM1/29/18
to AdWords API Forum
Thanks Vicent. I'll post it there.
Reply all
Reply to author
Forward
0 new messages