1. Caddy version (caddy version
):
./caddy version
v2.4.6 h1:HGkGICFGvyrodcqOOclHKfvJC0qTU7vny/7FhYp9hNw=
2. How I run Caddy:
I am trying something out and run caddy as non root user on the command line as for my test I don’t need higher privileges.
a. System environment:
Linux Mint 20.2
b. Command:
$ pwd
/tmp/tmp.DeLqOfdK5w
$ ./caddy run
c. Service/unit/compose file:
N/A
d. My complete Caddyfile or JSON config:
{
"storage": {
"module": "file_system",
"root": "/tmp/tmp.DeLqOfdK5w"
},
"apps": {
"pki": {
"certificate_authorities": {
"customca": {
"name": "my custom CA name",
"root_common_name": "custom CA - root",
"intermediate_common_name": "custom CA - intermediate",
"install_trust": false,
"root": {},
"intermediate": {}
}
}
}
}
}
3. The problem I’m having:
I am trying to get Caddy to create a local CA in my temporary directory so that I can later use it with more configuration to create certificates off of it.
When applying the configuration above, Caddy throws an unexpected error of “no such file or directory”.
4. Error messages and/or full log output:
When trying to set the configuration above I get this:
$ curl localhost:2019/load -X POST -H "Content-Type: application/json" -d @caddy.json
{"error":"loading config: loading new config: loading pki app module: provision pki: provisioning CA 'customca': open : no such file or directory"}
./caddy run
2021/12/02 21:23:41.766 INFO admin admin endpoint started {"address": "tcp/localhost:2019", "enforce_origin": false, "origins": ["127.0.0.1:2019", "localhost:2019", "[::1]:2019"]}
2021/12/02 21:23:41.766 INFO serving initial configuration
2021/12/02 21:23:52.969 INFO admin.api received request {"method": "POST", "host": "localhost:2019", "uri": "/load", "remote_addr": "127.0.0.1:46260", "headers": {"Accept":["*/*"],"Content-Length":["368"],"Content-Type":["application/json"],"User-Agent":["curl/7.68.0"]}}
2021/12/02 21:23:52.969 INFO admin admin endpoint started {"address": "tcp/localhost:2019", "enforce_origin": false, "origins": ["localhost:2019", "[::1]:2019", "127.0.0.1:2019"]}
2021/12/02 21:23:52.971 ERROR admin.api request error {"error": "loading config: loading new config: loading pki app module: provision pki: provisioning CA 'customca': open : no such file or directory", "status_code": 400}
2021/12/02 21:23:52.974 INFO admin stopped previous server {"address": "tcp/localhost:2019"}
My thought was that Caddy would create the directories needed in the root dir.
Is this assumption correct? What do I have to do to to get the above working?
5. What I already tried:
I checked out the API documentation, searched the forum as well as GitHub issues for tickets or posts containing the phrase “certificate_authorities” to maybe find others with similar problems.
As I couldn’t find any, I’m posting here
The documentation at JSON Config Structure - Caddy Documentation states the following:
The root certificate to use; if null, one will be generated.
I am somewhat under the impression that the error and this is somewhat related but from the docs it isn’t clear.
I also am not a Go dev so I haven’t read the code (also I don’t think that reading the code would help me or is the way to go anyway).