I am trying to use Caddy purely with self generated certs.
I don’t understand why it tries to install a root ca in this case
2. Error messages and/or full log output:
$ caddy run --config caddy/Caddyfile
2023/03/11 15:46:14.783 INFO using provided configuration {"config_file": "caddy/Caddyfile", "config_adapter": ""}
2023/03/11 15:46:14.783 WARN Caddyfile input is not formatted; run the 'caddy fmt' command to fix inconsistencies {"adapter": "caddyfile", "file": "caddy/Caddyfile", "line": 2}
2023/03/11 15:46:14.784 INFO admin admin endpoint started {"address": "localhost:2019", "enforce_origin": false, "origins": ["//localhost:2019", "//[::1]:2019", "//127.0.0.1:2019"]}
2023/03/11 15:46:14.784 INFO tls.cache.maintenance started background certificate maintenance {"cache": "0x140001becb0"}
2023/03/11 15:46:14.784 WARN tls stapling OCSP {"error": "no OCSP stapling for [media.home]: no OCSP server specified in certificate"}
2023/03/11 15:46:14.784 INFO http enabling automatic HTTP->HTTPS redirects {"server_name": "srv0"}
2023/03/11 15:46:14.785 INFO tls cleaning storage unit {"description": "FileStorage:/Users/tcurdt/Library/Application Support/Caddy"}
2023/03/11 15:46:14.785 INFO tls finished cleaning storage units
2023/03/11 15:46:14.798 WARN pki.ca.local installing root certificate (you might be prompted for password) {"path": "storage:pki/authorities/local/root.crt"}
2023/03/11 15:46:14.893 INFO failed to execute "keytool -list": exit status 1
keytool error: java.lang.Exception: Keystore file does not exist:
Password:
Thanks. So that’s why: the certificate only contains a CommonName (deprecated, btw) for media.home, not localhost, so Caddy still needs to generate a cert for localhost.
Aaaah! I didn’t realize it would have to match - but in retrospect that makes sense.
Should the mismatch be in the logs, maybe? I might have the log level set not verbose enough.
And how should it look like non-deprecated?
While I’ve set CN, subjectAltName should also be set. But I don’t see anything in the SAN.
There are debug logs that should emit more info. We could probably also emit debug logs when we load external certs too.
Yeah, set a SAN. I’d suggest even doing it instead of CN – just be aware that some cert viewers handle empty-CN names kinda weird (like Firefox’s cert viewer!).
Just cause I’m a purist There’s no reason to keep CN – unless you have a very antiquated relying party software that doesn’t read SANs or for some reason expects CN, even though they’re deprecated.
Anyway, it doesn’t matter if it has a CN. But the SAN definitely has to match your site!