N4S4 / synology-api

A Python wrapper around Synology API
MIT License
391 stars 143 forks source link

Proposal : allow skipping SSL certificates #54

Closed danieleTrimarchi closed 3 years ago

danieleTrimarchi commented 3 years ago

In my current netttwork the Synology NAS is local https - so we don't have SSL certificates.

I need to be able to set the flag "verify" when get_file or upload_file, in order to work around the SSLCertVerificationError (see the stack below)

Thanks, Daniele

--

Traceback (most recent call last): [...] File "C:\Users\danie\AppData\Local\Programs\Python\Python38\lib\site-packages\synology_api\filestation.py", line 1007, in get_file with session.get(url, stream=True, verify=verify) as r: File "C:\Users\danie\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\sessions.py", line 543, in get return self.request('GET', url, kwargs) File "C:\Users\danie\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\sessions.py", line 530, in request resp = self.send(prep, send_kwargs) File "C:\Users\danie\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\sessions.py", line 643, in send r = adapter.send(request, **kwargs) File "C:\Users\danie\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\adapters.py", line 514, in send raise SSLError(e, request=request) requests.exceptions.SSLError: HTTPSConnectionPool(host='10.37.0.103', port=5001): Max retries exceeded with url: /webapi/entry.cgi?api=SYNO.FileStation.Download&version=2&method=download&path=%2FShared%2FErrorNS.png&mode=download&sid=G1p2GJ4V0x-Eg7XZN9oEtCAwaxzwL-hXNn7n2eCqYIh77YWLynJDQtzOLArKj0NIL2qZtp-2-pcctmzLmUxWw (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)')))

N4S4 commented 3 years ago

ok i get the point as i forgot that get_file and upload_file do not use request data funtions, so it is not included in the certificate verification, there is some conflict in your PR with master branch ill try to see what is and final test

N4S4 commented 3 years ago

also if you dont mind to update your branch to the latest to avoid conflicts, if is a issue i can resovle conflicts afterwards, check the review I've just posted please

danieleTrimarchi commented 3 years ago

Conflict resolved !

danieleTrimarchi commented 3 years ago

looks brilliant to me! (and sorry for the typo ! ) can you proceed with the merge ?

danieleTrimarchi commented 3 years ago

hi, can you please merge the pull request ?

N4S4 commented 3 years ago

Yes give me a couple of days for some more testing and i will merge, as soon I get home I will merge

danieleTrimarchi commented 3 years ago

Thanks Renato ! Just one more question : when is this landing to the pip distribution (pypi.org) ? I see latest version is 0.1.3.1 published on Dec,2020

N4S4 commented 3 years ago

It is done already check it out, if you see any issue with the pip package let me know as is only wheel package

danieleTrimarchi commented 3 years ago

I must have been too rushy on this : I just re uninstalled/installed the package and I have found the modifications

N4S4 commented 3 years ago

It's ok, glad it worked