Could not open SSL certificat, invalid argument

Hi,

I’ve been running Home Assistant on a VM using hassio image for something like a year.

I’m using my own domain with a wildcard certificate from AlphaSSL and things have been working fine since I’ve set that up.

This morning, unable to access the web interface. After playing around, I realized that my certificate has expired. I actually bought another wildcard certificate a month ago and just forgot to change the one used by HA.

So, I went and converted the certificate to the necessary format and just replaced both file (crt,pem and key.pem) used with the new one. No change to the config. Went and rebooted the VM itself.

Since then. the http service refuse to start, it always give the error “Could not read SSL certificate from /path/to/ssl.crt.pem : [ Errno 22 ] Invalid argument”

I’ve tried all certificate format I can think of (with the full chain included, without) and none seem to work.

If I revert back to the old certificate and keys, the error disappear and the http service seems to start but I am still unable to connect, probably due to the fact that the certificate is expired.

Any idea on what should be included in the certificate? Any special things that needs to be done?

I’m researching a similar error.

2021-02-07 12:07:23 ERROR (MainThread) [homeassistant.components.http] Could not read SSL certificate from /ssl/fullchain.pem: [Errno 22] Invalid argument

I think the issue is a missing password, but I’m not sure. And I’m not sure where to set up the password for the cert. Any ideas on the password part?

Sorry I can’t help, but please let me know how you solved it if you are able to. I’ll do the same if I am able to resolve.

AFAIK, you cannot use a password. You need to use a key file. You should have something like that in your configuration.yaml

http:
  ssl_certificate: /ssl/cefrtificate.crt.pem
  ssl_key: /ssl/private.key.pem

Depending on your certificate source, you might have to use openssl to convert it to the correct format and export the key.

Ok, I tested a whole bunch of stuff with the certificate but the problem was with the key. Somehow I missed a step somewhere and the key file was containing an encrypted key (requiring a password).

I exported it as an unencrypted key and now it works!

Hello, I’m having the same problem but I don’t have any idea on how to manage a key not encripted. Do you have any suggestion?
Thanks

Daniele