finish06 / pyunifi

https://unifi-sdn.ubnt.com/
MIT License
228 stars 99 forks source link

Support Unifi's insistence on ancient TLSv1 #53

Closed davidc closed 4 years ago

davidc commented 4 years ago

Connecting (at least with Python 3.7) gives the error:

requests.exceptions.SSLError: HTTPSConnectionPool(host='xxx', port=8443): Max retries exceeded with url: /api/login (Caused by SSLError(SSLError(1, '[SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:1056)')))

Caused by the Unifi controller supporting only TLS v1.

This can be resolved by manually adjusting your controller to support TLSv1.2, however given that Ubiquiti have deemed the default to be only TLSv1 support, this API probably should support it.

finish06 commented 4 years ago

Please confirm you have not set SSL to false.

davidc commented 4 years ago

Correct... that is an SSLError.

Here is the code, it works fine if you manually frig Unifi's settings to support TLSv1.2, but the average user should not be expected to do this, the default out of the box fresh controller install only supports TLS v1.

https://github.com/davidc/unifi-util/blob/master/unifiutil.py

finish06 commented 4 years ago

@davidc - What operating system are you using?

finish06 commented 4 years ago

After researching the topic, I am not aware of a means for the Requests package to handle TLS v1. This is definitely an problem however it is not something that can be fixed. Unifi needs to update to an acceptable security standard.