Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

requests.exceptions.SSLError > add option to call requests with param verify=False #36

Closed
ignalex opened this issue May 30, 2016 · 7 comments

Comments

@ignalex
Copy link

ignalex commented May 30, 2016

hi guys,
it is not s big issue, but if you are behind a corp firewall (I am) when trying to call tts.save, there is error with regards to SSL:

tts.save("hello.mp3")
Traceback (most recent call last):
File "", line 1, in
File "C:\Anaconda\lib\site-packages\gtts\tts.py", line 94, in save
self.write_to_fp(f)
File "C:\Anaconda\lib\site-packages\gtts\tts.py", line 114, in write_to_fp
r = requests.get(self.GOOGLE_TTS_URL, params=payload, headers=headers)
File "C:\Anaconda\lib\site-packages\requests\api.py", line 55, in get
return request('get', url, *_kwargs)
File "C:\Anaconda\lib\site-packages\requests\api.py", line 44, in request
return session.request(method=method, url=url, *_kwargs)
File "C:\Anaconda\lib\site-packages\requests\sessions.py", line 456, in request
resp = self.send(prep, *_send_kwargs)
File "C:\Anaconda\lib\site-packages\requests\sessions.py", line 559, in send
r = adapter.send(request, *_kwargs)
File "C:\Anaconda\lib\site-packages\requests\adapters.py", line 382, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError

it is fixed by modifying line 114 from
r = requests.get(self.GOOGLE_TTS_URL, params=payload, headers=headers)
to
r = requests.get(self.GOOGLE_TTS_URL, params=payload, headers=headers,verify=False)

could be helpful to maybe having it as an option configurable when building tts object.

Cheers
Alex

@foges
Copy link

foges commented Jul 28, 2016

Similar issue here. I get requests.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)

@jhoelzl
Copy link

jhoelzl commented Jul 28, 2016

Me too!

I can suppress the error when i add the option verify=False to the requests command in the gtts_token package on line 58.

However, i am also searching for a better solution ...

@wallygit
Copy link

wallygit commented Jan 6, 2017

Hello,
I installed gtts using "pip install gTTS" and I get the ssl error when trying the commandline utility:
gtts-cli.py "Hello" -l 'en' -o hello.mp3
[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:600)

I tried to reinstall requests and certifi but no change.
How should I try the above approach ?

r = requests.get(self.GOOGLE_TTS_URL, params=payload, headers=headers)
change to
r = requests.get(self.GOOGLE_TTS_URL, params=payload, headers=headers,verify=False)

After changing .../gTTS-master/gtts/tts.py line 114 I assume I have to rbuild the utility (?)
Simply using "pip install gTTS" again, seems to download a fresh source and my changes are ignored.
I'm not experienced with Python stuff at all, I just need to use the tool to make some text available for vison impaired. Any help highly welcome, thx.

Tried to change line 114 in /usr/lib/python3.4/site-packages/gtts/tts.py
but the error remains.

@ruapotato
Copy link

Work around:

in
/usr/lib/python3.4/site-packages/requests/sessions.py

change line 572 from:

        # Send the request
        r = adapter.send(request, **kwargs)

to read

        # Send the request
        kwargs['verify'] = False
        r = adapter.send(request, **kwargs)

@wallygit
Copy link

works now, thank you very much !

@pndurette
Copy link
Owner

pndurette commented Apr 15, 2017

Hi! gTTS 1.2.0 was released, fixing this. SSL verify is now always false, since we can live w/o it in our case.

@souzaavi
Copy link

souzaavi commented Jun 3, 2017

After making changes use these lines of code in the file where u are using tts.save() to avoid warnings.

import urllib3

urllib3.disable_warnings()

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants