caddy always put certificate files in ~/.local/share/certmagic

Created on 13 Feb 2019  路  3Comments  路  Source: caddyserver/caddy

1. What version of Caddy are you using (caddy -version)?

master branch, 1867ded1

2. What are you trying to do?

Start caddy with HTTPS sites.

3. What is your entire Caddyfile?

domain.name {
}

4. How did you run Caddy (give the full command and describe the execution environment)?

CADDYPATH=./testdir caddy

5. Please paste any relevant HTTP request(s) here.

None

6. What did you expect to see?

Certificate files(directories acme, locks and ocsp) in testdir.

7. What did you see instead (give full error messages and/or log)?

Those files are in ~/.local/share/certmagic

8. How can someone who is starting from scratch reproduce the bug as minimally as possible?

rm -rf testdir ~/.local/share/certmagic
echo 'domain.name {\n}' > Caddyfile
CADDYPATH=./testdir caddy
# maybe
# sudo setcap 'cap_net_bind_service=+ep' `which caddy`
ls ~/.local/share/certmagic
ls testdir

This bug is introduced by 1867ded1

Before it, the CADDYPATH was wrote to certmagic.DefaultStorage in function Start
https://github.com/mholt/caddy/commit/1867ded14c82cd2ab296df8d783bbc880360d37d#diff-8632679e3877ee0e47ef75b20c92458eL492

After it, this will happen in function setupTLS
https://github.com/mholt/caddy/commit/1867ded14c82cd2ab296df8d783bbc880360d37d#diff-4a6ec435228114043bb89221e30e51f9R46

But certmagic.DefaultStorage is read in function NewConfig and NewWithCache, which happens before setupTLS .
So the new value written by setupTLS is ineffective.

bug

All 3 comments

Dang, thanks for the report. Strange that this wasn't caught in dev/testing.

@crvv Would you like an invite to our Caddy Slack? Let me know your email and I can send you one.

Yes, thanks.
Please send it to my email in git history.
cd $GOPATH/src/github.com/mholt/caddy; git log 78455c7cb9c

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wayneashleyberry picture wayneashleyberry  路  3Comments

jgsqware picture jgsqware  路  3Comments

klaasel picture klaasel  路  3Comments

kilpatty picture kilpatty  路  3Comments

SteffenDE picture SteffenDE  路  3Comments