I was going through a Google tutorial to connect Google Sheets with python here. I am running this piece of code behind a corporate proxy, therefore the certificates received are already replaced by the proxy server.
I have created token.pickle
file on a non-proxy machine and transferred it here. I get certificate verification failure at this line of the code given in the guide:
service = build('sheets', 'v4', credentials=creds)
The error that comes up is:
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1076)
I dig out into the build method here. Upon searching through the source codes, I found out that creds and http object as parameters to this method are mutually exclusive, I.e. when I pass creds
object, I can't pass a http
object to this function.
If I could pass a httplib2.http
object, I would have set it to disable SSL verification. But now with this wrapper around, I cannot find any way out to specify this.
I tried the following two hacks also:
- Creating a unverified context:
ssl._create_default_https_context = ssl._create_unverified_context
- Setting
PYTHONHTTPSVERIFY=0
as a env variable
But none of them works. I have my corporate proxy certificate installed in my ca-bundle, and the .cer file too.