With SSL on false and true
bash-5.1# python3 unifi_ap.py
/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py:1013: InsecureRequestWarning: Unverified HTTPS request is being made to host ‘192.168.179.202’. Adding certificate verification is strongly advised. See: Advanced Usage - urllib3 1.26.6 documentation
warnings.warn(
Traceback (most recent call last):
File “/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py”, line 699, in urlopen
httplib_response = self._make_request(
File “/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py”, line 445, in _make_request
six.raise_from(e, None)
File “”, line 3, in raise_from
File “/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py”, line 440, in _make_request
httplib_response = conn.getresponse()
File “/usr/local/lib/python3.9/http/client.py”, line 1349, in getresponse
response.begin()
File “/usr/local/lib/python3.9/http/client.py”, line 316, in begin
version, status, reason = self._read_status()
File “/usr/local/lib/python3.9/http/client.py”, line 285, in _read_status
raise RemoteDisconnected(“Remote end closed connection without”
http.client.RemoteDisconnected: Remote end closed connection without response
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “/usr/local/lib/python3.9/site-packages/requests/adapters.py”, line 439, in send
resp = conn.urlopen(
File “/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py”, line 755, in urlopen
retries = retries.increment(
File “/usr/local/lib/python3.9/site-packages/urllib3/util/retry.py”, line 532, in increment
raise six.reraise(type(error), error, _stacktrace)
File “/usr/local/lib/python3.9/site-packages/urllib3/packages/six.py”, line 769, in reraise
raise value.with_traceback(tb)
File “/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py”, line 699, in urlopen
httplib_response = self._make_request(
File “/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py”, line 445, in _make_request
six.raise_from(e, None)
File “”, line 3, in raise_from
File “/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py”, line 440, in _make_request
httplib_response = conn.getresponse()
File “/usr/local/lib/python3.9/http/client.py”, line 1349, in getresponse
response.begin()
File “/usr/local/lib/python3.9/http/client.py”, line 316, in begin
version, status, reason = self._read_status()
File “/usr/local/lib/python3.9/http/client.py”, line 285, in _read_status
raise RemoteDisconnected(“Remote end closed connection without”
urllib3.exceptions.ProtocolError: (‘Connection aborted.’, RemoteDisconnected(‘Remote end closed connection without response’))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “/config/script/unifi_ap.py”, line 17, in
client = Controller(host, username, password, port, version,
File “/usr/local/lib/python3.9/site-packages/pyunifi/controller.py”, line 113, in init
self._login()
File “/usr/local/lib/python3.9/site-packages/pyunifi/controller.py”, line 185, in _login
response = self.session.post(
File “/usr/local/lib/python3.9/site-packages/requests/sessions.py”, line 590, in post
return self.request(‘POST’, url, data=data, json=json, **kwargs)
File “/usr/local/lib/python3.9/site-packages/requests/sessions.py”, line 542, in request
resp = self.send(prep, **send_kwargs)
File “/usr/local/lib/python3.9/site-packages/requests/sessions.py”, line 655, in send
r = adapter.send(request, **kwargs)
File “/usr/local/lib/python3.9/site-packages/requests/adapters.py”, line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: (‘Connection aborted.’, RemoteDisconnected(‘Remote end closed connection without response’))
bash-5.1# python3 unifi_ap.py
Traceback (most recent call last):
File “/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py”, line 699, in urlopen
httplib_response = self._make_request(
File “/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py”, line 382, in _make_request
self._validate_conn(conn)
File “/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py”, line 1010, in validate_conn
conn.connect()
File “/usr/local/lib/python3.9/site-packages/urllib3/connection.py”, line 411, in connect
self.sock = ssl_wrap_socket(
File "/usr/local/lib/python3.9/site-packages/urllib3/util/ssl.py", line 453, in ssl_wrap_socket
ssl_sock = ssl_wrap_socket_impl(sock, context, tls_in_tls)
File "/usr/local/lib/python3.9/site-packages/urllib3/util/ssl.py", line 495, in _ssl_wrap_socket_impl
return ssl_context.wrap_socket(sock)
File “/usr/local/lib/python3.9/ssl.py”, line 500, in wrap_socket
return self.sslsocket_class._create(
File “/usr/local/lib/python3.9/ssl.py”, line 1040, in _create
self.do_handshake()
File “/usr/local/lib/python3.9/ssl.py”, line 1309, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:1129)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “/usr/local/lib/python3.9/site-packages/requests/adapters.py”, line 439, in send
resp = conn.urlopen(
File “/usr/local/lib/python3.9/site-packages/urllib3/connectionpool.py”, line 755, in urlopen
retries = retries.increment(
File “/usr/local/lib/python3.9/site-packages/urllib3/util/retry.py”, line 574, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host=‘192.168.179.202’, port=443): Max retries exceeded with url: /api/auth/login (Caused by SSLError(SSLCertVerificationError(1, ‘[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:1129)’)))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “/config/script/unifi_ap.py”, line 17, in
client = Controller(host, username, password, port, version,
File “/usr/local/lib/python3.9/site-packages/pyunifi/controller.py”, line 113, in init
self._login()
File “/usr/local/lib/python3.9/site-packages/pyunifi/controller.py”, line 185, in _login
response = self.session.post(
File “/usr/local/lib/python3.9/site-packages/requests/sessions.py”, line 590, in post
return self.request(‘POST’, url, data=data, json=json, **kwargs)
File “/usr/local/lib/python3.9/site-packages/requests/sessions.py”, line 542, in request
resp = self.send(prep, **send_kwargs)
File “/usr/local/lib/python3.9/site-packages/requests/sessions.py”, line 655, in send
r = adapter.send(request, **kwargs)
File “/usr/local/lib/python3.9/site-packages/requests/adapters.py”, line 514, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host=‘192.168.179.202’, port=443): Max retries exceeded with url: /api/auth/login (Caused by SSLError(SSLCertVerificationError(1, ‘[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:1129)’)))
also it looks like connecting to:
host=‘192.168.179.202’, port=443
but my settings are:
host = ‘192.168.179.202’
username = ‘Secret’
password = ‘Secret’
version = ‘UDMP-unifiOS’
site_id = ‘default’
port = ‘38193’