JoDehli / PyLoxone

Python Loxone binding
Apache License 2.0
162 stars 40 forks source link

SSL certificate Error when configuring #260

Closed schultza closed 1 month ago

schultza commented 1 month ago

Describe the bug

When I try to configure the plugin it fails with the following error

Firmware of your Miniserver

14.7.3.6

HomeAssistant install method

Running in VM on proxmoxserver in other VLAN than Miniserver (but ping is possible)

Version of HomeAssistant

Core 2024.3.3 Supervisor 2024.03.1 Operating System 12.1

Version of Pyloxone

Newest

Update pyloxone

yes

Log

Settings for the log can be found on the main page under the section Log Configuration Error setting up entry PyLoxone for loxone Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 504, in async_setup result = await component.async_setup_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/loxone/init.py", line 178, in async_setup_entry if not await miniserver.async_setup(): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/loxone/miniserver.py", line 133, in async_setup request_code = await self.lox_config.getJson() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/loxone/api.py", line 162, in getJson my_response = await client.get(LOXAPPPATH) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/httpx/_client.py", line 1801, in get return await self.request( ^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/httpx/_client.py", line 1574, in request return await self.send(request, auth=auth, follow_redirects=follow_redirects) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/httpx/_client.py", line 1661, in send response = await self._send_handling_auth( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/httpx/_client.py", line 1689, in _send_handling_auth response = await self._send_handling_redirects( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/httpx/_client.py", line 1726, in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/httpx/_client.py", line 1763, in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/httpx/_transports/default.py", line 373, in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/httpcore/_async/connection_pool.py", line 216, in handle_async_request raise exc from None File "/usr/local/lib/python3.12/site-packages/httpcore/_async/connection_pool.py", line 196, in handle_async_request response = await connection.handle_async_request( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/httpcore/_async/connection.py", line 99, in handle_async_request raise exc File "/usr/local/lib/python3.12/site-packages/httpcore/_async/connection.py", line 76, in handle_async_request stream = await self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/httpcore/_async/connection.py", line 154, in _connect stream = await stream.start_tls(*kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/httpcore/_backends/anyio.py", line 78, in start_tls raise exc File "/usr/local/lib/python3.12/site-packages/httpcore/_backends/anyio.py", line 69, in start_tls ssl_stream = await anyio.streams.tls.TLSStream.wrap( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/anyio/streams/tls.py", line 125, in wrap await wrapper._call_sslobject_method(ssl_object.do_handshake) File "/usr/local/lib/python3.12/site-packages/anyio/streams/tls.py", line 133, in _call_sslobject_method result = func(args) ^^^^^^^^^^^ File "/usr/local/lib/python3.12/ssl.py", line 917, in do_handshake self._sslobj.do_handshake() ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: IP address mismatch, certificate is not valid for '192.168.20.XX'. (_ssl.c:1000)

JoDehli commented 1 month ago

@schultza do you use SSL. SSL is not supported.

schultza commented 1 month ago

No actually not

JoDehli commented 1 month ago

Did it work in the past or never? Did you enable local access? Pyloxone can only connect locally with the IP. And please do not use port 80. Is a different port.

schultza commented 1 month ago

Never before. It's a fresh home assistant install inside a proxmox server. What do you mean by enabling local access? On loxone side?

JoDehli commented 1 month ago

Yes it is a loxone setting. I think it is disabled by default. Then change the port to a different then 80 and tyy it again with the local IP address

schultza commented 1 month ago

I tried also the port 443 (as given in the loxone config) and 8080.

Where can I change the local access setting?

JoDehli commented 1 month ago

@schultza this is a loxone settings please look in the documentation of loxone. I think if you search for local access you will get enough Infos. There you can specify also the port. I think the port 8080 will not work when you not have configured it on loxone. You must define it on loxone first. And the 443 will not work as I said SSL is not working.

gigatexel commented 1 month ago

I tried also the port 443 (as given in the loxone config) and 8080.

Where can I change the local access setting?

Connect to Miniserver using Loxone Config Select the Minisever in the tree and select Configure Miniserver at the top. Select Network tab Configure the HTTP port. I chose 81. Use this port in pyLoxone.

schultza commented 1 month ago

I can change the settings but dont have external access to the miniserver anymore. (did not yet check if Pyloxone works)

schultza commented 1 month ago

But still no access: image Port is the same as in the second picture the http port. image I verified that the ip adress is correct

gigatexel commented 1 month ago

But still no access:

I think you are not following the steps I described. You are lookin at the remote access tab, not the network tab.

schultza commented 1 month ago

You are right. I now change the port on the network tab as described. image image

gigatexel commented 1 month ago

and does it work now?

schultza commented 1 month ago

Sorry, somehow deleted the line :-(

No it does not image

gigatexel commented 1 month ago

What's in the logs?

schultza commented 1 month ago
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 504, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/loxone/__init__.py", line 178, in async_setup_entry
    if not await miniserver.async_setup():
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/loxone/miniserver.py", line 133, in async_setup
    request_code = await self.lox_config.getJson()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/loxone/api.py", line 162, in getJson
    my_response = await client.get(LOXAPPPATH)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/httpx/_client.py", line 1801, in get
    return await self.request(
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/httpx/_client.py", line 1574, in request
    return await self.send(request, auth=auth, follow_redirects=follow_redirects)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/httpx/_client.py", line 1661, in send
    response = await self._send_handling_auth(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/httpx/_client.py", line 1689, in _send_handling_auth
    response = await self._send_handling_redirects(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/httpx/_client.py", line 1747, in _send_handling_redirects
    raise exc
  File "/usr/local/lib/python3.12/site-packages/httpx/_client.py", line 1729, in _send_handling_redirects
    await hook(response)
  File "/config/custom_components/loxone/api.py", line 84, in raise_if_not_200
    raise LoxoneHTTPStatusError(
custom_components.loxone.api.LoxoneHTTPStatusError: Miniserver response code 401
schultza commented 1 month ago

Credentials were wrong .... now it seems to work!

gigatexel commented 1 month ago

Great, can you close this then?

schultza commented 1 month ago

Yep I wanted just to check whether it really works now.

Thanks @gigatexel and @JoDehli for this great and fast support! Really appreciating this!

schultza commented 1 month ago

Closed: Port configuration wasnt correct and wrong credentials