Hey,
yesterday i installed the version 0.44 of HA. After setting up the new certificate expiry-sensor with
host: my.domain.com
I get the error
[homeassistant.components.sensor.cert_expiry] Cannot connect to my.domain.com
after restarting HA and the state of the sensor is “unknown”. HA runs on port 443.
The same issue with the sensor.
I was not able to get it work.
I think the problem is the missing automatic redirect/change of the protocol from http to https. The other tested sites automatically redirect to https if they are called with http - my homeassistant-setup doesn´t redirect automatically. Is there a way to do it?
It appears that the sensor cannot get data (cannot connect) during the HASS start, however, after the first update (interval update is 12 hours) it shows days left as expected.
Perhaps, it should be fixed in the sensor’s code to fetch data after HASS server is up.
Okay, then i should control myself and wait 12 hours before next restart. Actually i play with HA very often and try this and that… it doesn´t run for 12 hours continously
Yep, that´s the solution. I changed the scan_interval to 5 minutes and now it will be shown. It would be great, if you can set up the interval in the component-setup
How did you change this?
I changed it directly in the code of homeassistant, but with every update of HA this will be overwritten. The path is /HA-Path/lib/python3.4/site-packages/homeassistant/components/sensor/cert_expiry.py:24
Okay, so not something Joe Average (i.e. me) can really touch. That’s a bit irritating.
You can try to add scan_interval: 3600
to the configuration of the sensor.
Apparently the sensor doesn’t have that built into it yet. Someone else requested that as a feature.
That was me
I wasn’t able to make it work, so I created bash script to get the required information and use command_line sensor to display data in the Home Assistant.
I’ve the abilty set the update interval in yaml. I dont know python very well yet but seen to work for me.
- platform: cert_expiry
host: “www.google.com”
name: Google
port: 443
scan_interval: “00:05”
I use an automation that runs 15 seconds after hass startup and calls the homeassistant.update_entity service for the sensor.ssl_certificate_expiry. This way it updates without the 12 wait.
Posted this separately as well but does this work and also does it work with third party certs? I get the following in the logs:
2020-01-25 12:02:39 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 109, in async_init
result = await self._async_handle_step(flow, flow.init_step, data)
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 172, in _async_handle_step
result: Dict = await getattr(flow, method)(user_input)
File "/usr/src/homeassistant/homeassistant/components/cert_expiry/config_flow.py", line 116, in async_step_import
return await self.async_step_user(user_input)
File "/usr/src/homeassistant/homeassistant/components/cert_expiry/config_flow.py", line 79, in async_step_user
if await self._test_connection(user_input):
File "/usr/src/homeassistant/homeassistant/components/cert_expiry/config_flow.py", line 50, in _test_connection
get_cert, host, user_input.get(CONF_PORT, DEFAULT_PORT)
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/src/homeassistant/homeassistant/components/cert_expiry/helper.py", line 12, in get_cert
with socket.create_connection(address, timeout=TIMEOUT) as sock:
File "/usr/local/lib/python3.7/socket.py", line 728, in create_connection
raise err
File "/usr/local/lib/python3.7/socket.py", line 716, in create_connection
sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
2020-01-25 12:02:39 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/cert_expiry/config_flow.py", line 50, in _test_connection
get_cert, host, user_input.get(CONF_PORT, DEFAULT_PORT)
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/src/homeassistant/homeassistant/components/cert_expiry/helper.py", line 13, in get_cert
with ctx.wrap_socket(sock, server_hostname=address[0]) as ssock:
File "/usr/local/lib/python3.7/ssl.py", line 423, in wrap_socket
session=session
File "/usr/local/lib/python3.7/ssl.py", line 870, in _create
self.do_handshake()
File "/usr/local/lib/python3.7/ssl.py", line 1139, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 109, in async_init
result = await self._async_handle_step(flow, flow.init_step, data)
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 172, in _async_handle_step
result: Dict = await getattr(flow, method)(user_input)
File "/usr/src/homeassistant/homeassistant/components/cert_expiry/config_flow.py", line 116, in async_step_import
return await self.async_step_user(user_input)
File "/usr/src/homeassistant/homeassistant/components/cert_expiry/config_flow.py", line 79, in async_step_user
if await self._test_connection(user_input):
File "/usr/src/homeassistant/homeassistant/components/cert_expiry/config_flow.py", line 60, in _test_connection
if "doesn't match" in err.args[0]:
TypeError: argument of type 'int' is not iterable
Have two entries for my sensors, one to my external facing HA URL and another to my home server for remote access. Both require a manual login so although I see some access denied errors not sure what that’s actually about.