1

I know similar questions have been asked before but I have read all of them and I still cannot figure out a solution for my problem.

I am basically working behind a corporate proxy, so when I do for a example a get request to Google with something like this:

import requests 
requests.get('https://www.google.es')

I immediately get an error which points towards a fail in certificate verification. After much reading I have found this post where you can get a sweet explanation of what is going on.

Some solutions I have tried are: 1.https://stackoverflow.com/a/42540637/8380638 2.https://stackoverflow.com/a/48636689/8380638

But still I could not make this work.

My main goal is using Google Translate API from google.cloud python module which uses requests on it. So it would be good to find some fix that goes further from adding a parameter into request.get() function.

m33n
  • 1,622
  • 15
  • 38
  • Can you curl the webpage? Out of curiosity, what OS do you run? If it's MacOS, then ```cd /usr/local/include ; ln -s ../opt/openssl/include/openssl ``` helped me when I was getting SSL errors. – Richard G May 22 '18 at 16:27
  • 1
    While you reference several questions and claim that you have tried something based on these, it is not clear what you've exactly tried. If your code fails because of certificate validation and the cause of this is a SSL intercepting corporate proxy then you have to add the CA of this proxy as trusted using the `verify` parameter. If this does not work then maybe you don't use the correct proxy CA. – Steffen Ullrich May 22 '18 at 16:44
  • Yes, I thought about that but my browser can work once I add the CA to it. So there is no problem with this. I have also been speaking with the team in charge of the proxy and they have tried to disable SSL interception for this case but the same error is appearing. There must be something really small that I am missing, any idea will be welcomed – m33n May 23 '18 at 12:56

2 Answers2

1

You can get the Google Translate API without using the requests library. Simply install the google-cloud-translate library and setup the required authentication on your Google Cloud Platform account as described in the documentation. Once completed, you can directly import the Translate API using the following line:

from google.cloud import translate
Atybzz
  • 327
  • 3
  • 14
1

I finally found the solution for this, but I forgot to post it.

You can use this to find the path where request library CAs are stored and add your own one at the end of the file.

import requests as r     
print(r.certs.where())
m33n
  • 1,622
  • 15
  • 38