nickovs / unificontrol

A high-level Python interface to the Unifi controller software
Apache License 2.0
96 stars 41 forks source link

SSL error when trying to use any function except the initial connection #24

Closed raakatz closed 3 years ago

raakatz commented 3 years ago

Hi there.

If I run only:

import unificontrol
import ssl

cert = ssl.get_server_certificate(('hostname', 8443))
controller = unificontrol.UnifiClient(host='hostname', username='support', password='passoword', cert=cert, port=8443)

Then it runs and exits with no errors.

But as soon as I write a new line, for example:

controller.list_sites()

I get this error: requests.exceptions.SSLError: HTTPSConnectionPool(host='hostname', port=8443): Max retries exceeded with url: /api/self/sites (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1123)')))

It does this with any function I enter

***I didn't write the actual hostname, username, and password in this post, but in the code they are 100% correct

raakatz commented 3 years ago

Solved, trick was to have ssl imported and also "cert=None" as an argument in the controller

menvol3 commented 3 years ago

Hi @raakatz ,

Could you please explain what you did to solve it ?

I’m receiving Max retries exceeded with url: /api/s/default/stat/guest (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:1125)')))

raakatz commented 3 years ago

Hey @menvol3

Solved, trick was to have ssl imported and also "cert=None" as an argument in the controller

Did this not work for you? That's really all I did. But one thing to think about is the function arguments that may have changed since I posted that issue. It happened to me once that I got several errors only to find out that the dev changed something in the module and I had to fix my code accordingly, so maybe it happened again