googleads / googleads-python-lib

The Python client library for Google's Ads APIs
Apache License 2.0
681 stars 974 forks source link

Suddenly facing SSL error issues #256

Closed johnpates closed 6 years ago

johnpates commented 6 years ago

Have been running the same script on Windows Server 2008 without issues for months. No script changes. Script still works fine on other PCs. Suddenly report downloader service throws an SSL error.

Python 3.6 Windows Server

Traceback (most recent call last): File "Sisense\app_dfpdata\getDFPData.py", line 194, in downloadReport File "site-packages\googleads\dfp.py", line 804, in DownloadReportToFile File "urllib\request.py", line 526, in open File "urllib\request.py", line 544, in _open File "urllib\request.py", line 504, in _call_chain File "urllib\request.py", line 1361, in https_open File "urllib\request.py", line 1320, in do_open urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:777)> Traceback (most recent call last): File "urllib\request.py", line 1318, in do_open File "http\client.py", line 1239, in request File "http\client.py", line 1285, in _send_request File "http\client.py", line 1234, in endheaders File "http\client.py", line 1026, in _send_output File "http\client.py", line 964, in send File "http\client.py", line 1400, in connect File "ssl.py", line 407, in wrap_socket File "ssl.py", line 814, in init File "ssl.py", line 1068, in do_handshake File "ssl.py", line 689, in do_handshake ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:777)

msaniscalchi commented 6 years ago

Hello John,

Thanks for the report! I've used the latest version to run code downloading a report using DFP's DataDownloader on Python 3 / Windows and have not been able to replicate.

That said, I've noticed a trend of Windows users reporting an SSL issue like this appearing out of the blue. Just as mysteriously as it materializes, the issue quietly resolves itself consistently--usually following a restart or reinstallation of Python. I suppose what I'm trying to say is... have you tried turning it off and on again? :-)

Of course, provided no configurations have changed, I'm not sure why Python would suddenly become unable to locate the certificate store on some Windows machines. Does that same machine have the same issue when accessing other HTTPS endpoints with Python?

Regards, Mark

msaniscalchi commented 6 years ago

I'll be closing this now with the expectation that my earlier suggestion resolved the issue.

kenguie commented 5 years ago

I'm having this issue currently on a mac. {"event": "error", "msg": "failed to generate dfp report: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:841)>"}

Trying to use the google ads api to add line items to a previous order.

A fresh order with new line items still works. I've reinstalled python and google ads with no luck

msaniscalchi commented 5 years ago

Hey Ken,

Thanks for the report! I recommend filing a new issue rather than commenting on a closed one, for purposes of ensuring that your report remains visible to us.

Issues similar to this one are reported to us occasionally, and there are a few known causes that can be tricky to troubleshoot. The network configuration of the machine running this library sometimes negatively impacts the SSL certificate verification step, which was added back in Python 2.7.9 as a security enhancement. Another slightly more mysterious cause is when the Python installation fails to locate the certificate store; as noted above, this seems to happen when an OS is updated or left running for a long period of time. Typically, restarting the machine and/or reinstalling Python resolves this issue.

Regards, Mark

kenguie commented 5 years ago

Thanks Mark, Actually, I commented here because it's so hard to explain what seems to be happening. It seems like the same issue.

In any case, if it was or wasn't, the problem was in adding new Line Items to previous orders, I needed to add the sizes as well.

I believe documentation said sizes was optional. Not so it seems after I went digging into the logs.

In any case, I can add all the Line Items I want now and don't get the SSL error.

Thanks!