thebino / rki_covid

🦠 Custom integration for Home Assistant to monitor covid numbers provided by Robert-Koch Institut
Apache License 2.0
40 stars 11 forks source link

API provides an invalid SSL Certificate #13

Closed thebino closed 3 years ago

thebino commented 3 years ago

Since this morning at 00:27 the entities do not provide any values.

Have restarted HA and find some log entries. The first entry is:

Error fetching rki_covid data: Error communicating with API: Cannot connect to host rki.marlon-lueckert.de:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:1125)')]

More Entries:

Error while setting up rki_covid platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 199, in _async_setup_platform
    await asyncio.shield(task)
  File "/config/custom_components/rki_covid/sensor.py", line 53, in async_setup_entry
    sensors = [
  File "/config/custom_components/rki_covid/sensor.py", line 54, in <listcomp>
    RKICovidNumbersSensor(coordinator, district, info_type) for info_type in SENSORS
  File "/config/custom_components/rki_covid/sensor.py", line 74, in __init__
    data = coordinator.data[district]
TypeError: 'NoneType' object is not subscriptable
Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request
    resp = await self._request_handler(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_app.py", line 499, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/web_middlewares.py", line 118, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 49, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 18, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 72, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 127, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 129, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 136, in post
    return await super().post(request)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 60, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 69, in post
    result = await self._flow_mgr.async_init(
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 130, in async_init
    result = await self._async_handle_step(
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 213, in _async_handle_step
    result: Dict = await getattr(flow, method)(user_input)
  File "/config/custom_components/rki_covid/config_flow.py", line 37, in async_step_user
    for case in sorted(coordinator.data.values(), key=lambda case: case.county):
AttributeError: 'NoneType' object has no attribute 'values'

_Originally posted by @Whippie72 in https://github.com/thebino/rki_covid/issues/9#issuecomment-760653507_

ulf78 commented 3 years ago

the SSL certificate does not match the FQDN of the API server :-( https://www.ssllabs.com/ssltest/analyze.html?d=rki.marlon%2dlueckert.de&ignoreMismatch=on&latest

ulf78 commented 3 years ago

maybe switch API base URL in const.py to https://api.corona-zahlen.org/districts https://api.corona-zahlen.org/docs/endpoints/districts.html

mi4mac commented 3 years ago

Logger: custom_components.rki_covid Source: helpers/update_coordinator.py:166 Integration: RKI Covid numbers (documentation, issues) First occurred: 1:10:01 AM (1 occurrences) Last logged: 1:10:01 AM Error fetching rki_covid data: Error communicating with API: Cannot connect to host rki.marlon-lueckert.de:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:1125)')]

rolandsteinmeyer commented 3 years ago

Author of api writes in https://github.com/marlon360/rki-covid-api/ that rki has blocked him for excessive traffic. so we need to wait if this can be resolved at all.

rolandsteinmeyer commented 3 years ago

Workaround to get data directly from rki:

https://www.reddit.com/r/homeassistant/comments/jbujm5/german_corona_actions_threshold_gauge_number_of/

thebino commented 3 years ago

I have mixed feelings with changing the API: 1) using the RKI api directly could lead to the same excessive traffic and RKI will close the api for everyone. 2) build / fork marlons' API and add caching

hajo62 commented 3 years ago

Although it's a bit off topic: Some example API calls might be useful: i.e 7 Day Incidence for Germany, same for a Landkreis, ... For Cologne: https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/RKI_Landkreisdaten/FeatureServer/0/query?where=GEN%20%3D%20%27Köln%27&outFields=cases7_per_100k&returnGeometry=false&f=json But how would it look for Germany in total?

ulf78 commented 3 years ago

APIs für alle level DE https://npgeo-corona-npgeo-de.hub.arcgis.com/datasets/dd4580c810204019a7b8eb3e0b329dd6_0 Bundesländer https://npgeo-corona-npgeo-de.hub.arcgis.com/datasets/ef4b445a53c1406892257fe63129a8ea_0 Landkreise https://npgeo-corona-npgeo-de.hub.arcgis.com/datasets/917fc37a709542548cc3be077a786c17_0

hajo62 commented 3 years ago

Yep, jedoch kriege ich Laie damit leider keine "Inzidenz für 7 Tage für Deutschland" hin...

cairon-ha commented 3 years ago

Is there a solution at the moment?

Whippie72 commented 3 years ago

API ist running :) Everything works again.

thebino commented 3 years ago

The API has been fixed by adding a Proxy to hide the servers IP Adress: https://github.com/marlon360/rki-covid-api/issues/65 Hopefully this Proxy will not also be blocked by RKI