Hello,
I am working with Hassio and AppDaemon.
Everything was running fine until I activated SSL with a self signed certificate.
Now AppDaemon is unable to connect to Home assistant.
I am getting SSL errors ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:777)
See the log extract at the end of this post.
Home assistant and AppDaemon run on the same Raspberry host.
As Openssl seems to be unavailable on Hassio, I built the security certificate with Openssl on my Linux Mint laptop.
In the browser, I can access my home assistant instance on https://XXX.XXX.XXX.XXX:8123.
I can use the RESTful API with Python and the Requests module and also with Curl.
So, the certificate looks to be good.
Can anyone help me solve the problem?
Hereby my configuration and an extract of the log
configuration.yaml
http:
ssl_certificate: /config/certificate.pem
ssl_key: /config/privkey.pem
appdaemon.yaml
AppDaemon:
threads: 10
app_dir: /config/AppDaemon/apps
errorfile: /config/AppDaemon/log_stderr.txt
logfile: /config/AppDaemon/log_stdout.txt
cert_verify: False
cert_path: /config/certificate.pem
HASS:
ha_url: https://XXX.XXX.XXX.XXX:8123
#HADashboard:
# dash_url: http://127.0.0.1:5050
# dash_dir: /config/AppDaemon/dashboards
When debug is activated in AppDaemon, the stdout log contains the following errors:
2017-12-30 12:07:46.782148 WARNING ------------------------------------------------------------
2017-12-30 12:07:51.795328 DEBUG get_ha_config()
2017-12-30 12:07:51.801388 DEBUG get_ha_config: url is https://XXX.XXX.XXX.XXX:8123/api/config
2017-12-30 12:07:51.888900 WARNING Unable to connect to Home Assistant, retrying in 5 seconds
2017-12-30 12:07:51.890062 WARNING ------------------------------------------------------------
2017-12-30 12:07:51.890908 WARNING Unexpected error:
2017-12-30 12:07:51.891722 WARNING ------------------------------------------------------------
2017-12-30 12:07:51.897198 WARNING Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 601, in urlopen
chunked=chunked)
File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 346, in _make_request
self._validate_conn(conn)
File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 850, in _validate_conn
conn.connect()
File "/usr/lib/python3.6/site-packages/urllib3/connection.py", line 326, in connect
ssl_context=context)
File "/usr/lib/python3.6/site-packages/urllib3/util/ssl_.py", line 329, in ssl_wrap_socket
return context.wrap_socket(sock, server_hostname=server_hostname)
File "/usr/lib/python3.6/ssl.py", line 407, in wrap_socket
_context=self, _session=session)
File "/usr/lib/python3.6/ssl.py", line 814, in __init__
self.do_handshake()
File "/usr/lib/python3.6/ssl.py", line 1068, in do_handshake
self._sslobj.do_handshake()
File "/usr/lib/python3.6/ssl.py", line 689, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:777)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/requests/adapters.py", line 440, in send
timeout=timeout
File "/usr/lib/python3.6/site-packages/urllib3/connectionpool.py", line 639, in urlopen
_stacktrace=sys.exc_info()[2])
File "/usr/lib/python3.6/site-packages/urllib3/util/retry.py", line 388, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='XXX.XXX.XXX.XXX', port=8123): Max retries exceeded with url: /api/config (Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:777)'),))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/AppDaemon/admain.py", line 422, in main
ha_config = utils.get_ha_config()
File "/usr/lib/python3.6/site-packages/AppDaemon/utils.py", line 347, in get_ha_config
r = requests.get(apiurl, headers=headers, verify=conf.certpath)
File "/usr/lib/python3.6/site-packages/requests/api.py", line 72, in get
return request('get', url, params=params, **kwargs)
File "/usr/lib/python3.6/site-packages/requests/api.py", line 58, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/lib/python3.6/site-packages/requests/sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python3.6/site-packages/requests/sessions.py", line 618, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python3.6/site-packages/requests/adapters.py", line 506, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='XXX.XXX.XXX.XXX', port=8123): Max retries exceeded with url: /api/config (Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:777)'),))