jrfernandes / ontario_energy_board

Home Assistant component that installs a sensor with the current energy rate for Ontario energy companies
MIT License
41 stars 10 forks source link

Error adding this integration #33

Closed IceDragonAL closed 10 months ago

IceDragonAL commented 10 months ago

I'm running the following:

The integration was working through HACs until today I noticed it failed to load. I tried removing the integration and re-add it and it keeps giving me an error "Config flow could not be loaded: 500 Internal Server Error Server got itself in trouble".

Log Details (ERROR) This error originated from a custom integration. Logger: aiohttp.server Source: custom_components/ontario_energy_board/config_flow.py:16 Integration: Ontario Energy Board (documentation, issues) First occurred: 3:49:02 PM (3 occurrences) Last logged: 4:51:34 PM

Error handling request Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 980, in _wrap_create_connection return await self._loop.create_connection(*args, **kwargs) # type: ignore[return-value] # noqa ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/asyncio/base_events.py", line 1112, in create_connection transport, protocol = await self._create_connection_transport( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/asyncio/base_events.py", line 1145, in _create_connection_transport await waiter File "/usr/local/lib/python3.11/asyncio/sslproto.py", line 575, in _on_handshake_complete raise handshake_exc File "/usr/local/lib/python3.11/asyncio/sslproto.py", line 557, in _do_handshake self._sslobj.do_handshake() File "/usr/local/lib/python3.11/ssl.py", line 979, in do_handshake self._sslobj.do_handshake() ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1002)

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request resp = await request_handler(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/aiohttp/web_app.py", line 504, in _handle resp = await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/aiohttp/web_middlewares.py", line 117, in impl return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware return await handler(request) ^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 148, in handle result = await handler(request, *request.match_info) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 149, in post return await super().post(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 72, in wrapper result = await method(view, request, data, args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 71, in post result = await self._flow_mgr.async_init( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/config_entries.py", line 847, in async_init flow, result = await task ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/config_entries.py", line 875, in _async_init result = await self._async_handle_step(flow, flow.init_step, data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 392, in _async_handle_step result: FlowResult = await getattr(flow, method)(user_input) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/ontario_energy_board/config_flow.py", line 39, in async_step_user companies_list = await get_energy_companies() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/ontario_energy_board/config_flow.py", line 16, in get_energy_companies async with session.get(RATES_URL) as response: File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 1141, in aenter self._resp = await self._coro ^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/aiohttp/client.py", line 536, in _request conn = await self._connector.connect( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 540, in connect proto = await self._create_connection(req, traces, timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 901, in _createconnection , proto = await self._create_direct_connection(req, traces, timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 1209, in _create_direct_connection raise last_exc File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 1178, in _create_direct_connection transp, proto = await self._wrap_create_connection( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/aiohttp/connector.py", line 982, in _wrap_create_connection raise ClientConnectorCertificateError(req.connection_key, exc) from exc aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host www.oeb.ca:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1002)')]

johnwalk61 commented 10 months ago

Same issue here. Last line indicates the SSL cert is having an issue.

nwf commented 10 months ago

FWIW, https://www.ssllabs.com/ssltest/analyze.html?d=www.oeb.ca&latest says that they're serving only their leaf certificate and relying on the client to provide not just the trust anchor ("DigiCert Global Root G2") but also the intermediate CA ("DigiCert Global G2 TLS RSA SHA256 2020 CA1"). Possibly the integration could ship these certs and use them, but also possibly someone should send them mail.

petervk commented 10 months ago

Same issue here. Is there a workaround or does the OEB just need to fix their site?

petervk commented 10 months ago

I emailed them about this. I don't really understand but I copied the text from @nwf's comment to hopefully point them in the right direction. A workaround would be great in the meantime in case they never fix this.

petervk commented 10 months ago

@jrfernandes could this be a way to get the integration to download the intermediate certificate? As the current setup for oeb.ca shows up as trusted in most browsers they may not fix this.

https://stackoverflow.com/a/69618487

IceDragonAL commented 10 months ago

Not sure what happened, but it started working today.