Import Caddy in go code and auto-agree to LetsEncrypt terms

I’m importing Caddy into a go project and starting a server with it. I’m interested in knowing how to disable the agree prompt when the server is starting. I tried with an ACME_AGREE env var but it doesn’t work. Any ideas?

From the Caddy documentation:

Command-line interface:

Flags:

-agree

Indicates that you have read and agree to the Let’s Encrypt Subscriber Agreement. If this flag is not specified, it is possible that Caddy will prompt you to agree to terms during runtime. Thus, this flag is recommended in automated environments.

@LewPayne That is the correct answer if invoking Caddy as a command, but when using it as a library, it is done differently in code.

Unfortunately, since we recently extracted CertMagic into its own repo and vendored it, I am not sure if the value is exposed in a way that you can set it pre-emptively.

I’ll look into this…

(Would be similar to certmagic.SelfSignedCA as certmagic.CA value by mschneider82 · Pull Request #27 · caddyserver/certmagic · GitHub I guess.)

Allow me to piggyback my simple Q in this thread.

I’m looking for a simple code that allows me to import Caddy into my go project and starting a server with it.

It might be extremely trivial in the eyes of those who can. Can somebody help please, @Romeo_Mihalcea/@matt?

THX a lot!

Look at caddy package - github.com/mholt/caddy - pkg.go.dev

(Also, we no longer use vendor, so that won’t be a problem anymore.)

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.