I am trying to use rest-server 0.13.0 with TLS in a local network and restic 0.18.0. I could use SSH but would like to use the --append-only feature of rest-server.
But I get the error: “tls: failed to verify certificate: x509: certificate is not valid for any names, but wanted to match myhost”. This is most likely my wrong usage of openssl and certificates and not rest-server’s fault. But I hope someone could help me out.
If you have a domain, you could get a valid tls certificate from let’s encrypt via a dns challenge. Such certificates should work on the client right away.
Otherwise, this thread seem to cover what you are intending to do: Unable to use TLS client certificate
Does openssl x509 -text -in rest-cert.pem show both the IP and DNS name?
How exactly are you calling restic, in particular how do you pass the CA cert to it?
Try to copy self-signed CA certificate (ca-cert.pem from your example) to client. Use it when run backups (or any restic command) command restic backup --cacert PATH_TO_CA_CERT/ca-cert.pem ...
Extensions in certificates are not transferred to certificate requests and vice versa.
So I need to add the subjectAltName part when creating the certificate (openssl x509 …) instead of when creating the certification request (openssl req …).
I tried both --cacert path/to/ca-cert.pem and export RESTIC_CACERT=path/to/ca-cert.pem.
Now, it works! Thank you, @MichaelEischer for asking the right questions!
[req]
prompt = no
default_bits = 4096
utf8 = yes
distinguished_name = dn
req_extensions = req_ext
[dn]
C = DE
ST = State
L = City
O = Org
OU = Unit
CN = Server
emailAddress = me@example.com
[req_ext]
subjectAltName = @alt_names
[alt_names]
DNS.1 = my.local
IP.1 = 192.168.0.5