simon-weber / gmusicapi

An unofficial client library for Google Music.
https://unofficial-google-music-api.readthedocs.io
BSD 3-Clause "New" or "Revised" License
2.49k stars 258 forks source link

Add possibility to ignore SSL certificates on connecting to Google APIs #196

Closed deradam closed 10 years ago

deradam commented 10 years ago

I am trying to get your API running on a QNAP NAS which is lacking a proper SSL certificate installation and therefore does not succeed in connecting via HTTPS to the google servers.

Could you somehow add a optional configurable "ignore verification" flag to the request stuff?

From the documentation:

verify – (optional) if True, the SSL cert will be verified. A CA_BUNDLE path can also be provided.

Attached my stacktrace with the SSL error:

File "/share/MD0_DATA/.qpkg/Python/lib/python2.7/site-packages/gmusicapi-3.0.0_dev-py2.7.egg/gmusicapi/session.py", line 30, in _send_without_auth res = rsession.request(_req_kwargs) File "/share/MD0_DATA/.qpkg/Python/lib/python2.7/site-packages/requests-2.0.1-py2.7.egg/requests/sessions.py", line 361, in request resp = self.send(prep, _send_kwargs) File "/share/MD0_DATA/.qpkg/Python/lib/python2.7/site-packages/requests-2.0.1-py2.7.egg/requests/sessions.py", line 464, in send r = adapter.send(request, **kwargs) File "/share/MD0_DATA/.qpkg/Python/lib/python2.7/site-packages/requests-2.0.1-py2.7.egg/requests/adapters.py", line 363, in send raise SSLError(e) requests.exceptions.SSLError: [Errno 218603680] _ssl.c:549: error:0D07A0A0:asn1 encoding routines:ASN1_mbstring_copy:unknown format

simon-weber commented 10 years ago

Sure, exposing ssl verification at the client level seems reasonable. To see if this would actually fix your problem, try adding something like req_kwargs['verify'] = False to the beginning of gmusicapi.session._Base.send.

deradam commented 10 years ago

Hey Simon, thanks for the quick feedback. Added the line and it seems to work. I checked it using the mobile_devices script from here: https://github.com/hechtus/squeezebox-googlemusic/blob/master/mobile_devices.py Thanks for your support and please make that configurable at the client level ;)

simon-weber commented 10 years ago

Good to hear that worked for you! I'll leave this issue open until this is added to the client interfaces.

deradam commented 10 years ago

Hey Simon, there are still some issues with the squeezebox plugin (see here: https://github.com/hechtus/squeezebox-googlemusic/issues/18#issuecomment-30054198). Do I have to deactivate the verification in more files/classes than session._Base?

Update: Upgraded to the latest dev version (3.1.0-dev) and adapted the Squeezebox Plugin code to skip the verification and it is running like a charme! Thanks for your support and the prompt reaction!

simon-weber commented 10 years ago

Glad to hear it's working =)