Skip to content

chore: Prevent "certbot is not available" warning by Caddy #796

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 27, 2025

Conversation

7-zete-7
Copy link
Contributor

@7-zete-7 7-zete-7 commented May 27, 2025

By default, Caddy expects to run in the operating system, not in a container. Because of this, Caddy's default behavior is to install its certificate as trusted (see https://caddyserver.com/docs/automatic-https#ca-root). This makes no sense in a container. This template's containers don't require this. However, Caddy will notify you if it fails to install the certificate as trusted with the following warning:

INFO    warning: "certutil" is not available, install "certutil" with "apt install libnss3-tools"  or "yum install nss-tools" and try again

Since v2.4.2, Caddy has a global option skip_install_trust that disables Caddy's attempts to install its certificate as trusted. Having this global option disables this warning and may slightly improve container startup speed.

Fixes #764

Copy link
Owner

@dunglas dunglas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can even remove the comment IMHO

@7-zete-7 7-zete-7 force-pushed the caddy-certutil-warning branch from 74180fe to 11e6cf3 Compare May 27, 2025 13:26
@dunglas dunglas merged commit 6884829 into dunglas:main May 27, 2025
2 checks passed
@dunglas
Copy link
Owner

dunglas commented May 27, 2025

Thanks!!

@francislavoie
Copy link

This makes no sense in a container

That's not quite true. Caddy needs to have its own cert in the trust store if you're doing something like having Caddy connect to itself (e.g. reverse_proxy https://localhost, which is a valid usecase in certain situations.

@7-zete-7
Copy link
Contributor Author

7-zete-7 commented Jun 3, 2025

Thanks for pointing this out, @francislavoie!

I've made this statement more specific in the PR description.

For context, I'll attach a link to the HTTPS testing proposed in this template below. It uses the -k/--insecure cURL option. This template does not require trusting Caddy's own certificate for correct operation.

-
name: Check HTTPS reachability
if: false # Remove this line when the homepage will be configured, or change the path to check
run: curl -vk --fail-with-body https://localhost

@francislavoie
Copy link

-k basically turns off all security, meaning using HTTPS has no advantage at all over HTTP because it can be trivially man-in-the-middle'd. IMO, either default to HTTP for dev, or document clearly how to install the cert (covered here in Caddy docs https://caddyserver.com/docs/running#local-https-with-docker)

@7-zete-7
Copy link
Contributor Author

7-zete-7 commented Jun 4, 2025

@francislavoie , I agree with you. IMO the -k option should not be used if there are other solutions (double-checked). By using the -k option, I meant that trusting the Caddy certificate is not required by default in this template.

Also this repository already has a document describing several ways to fix the HTTPS issue (see TLS Certificates). A method similar to the one proposed in the Caddy documentation is suggested first.

AFAIU this template does not plan to install the libnss3-tools package. Because of this, the check for the certutil utility will always fail with a warning. This PR essentially disables the check and hides the warning.

With the global skip_install_trust option, Caddy's internal certificates are still generated and used. If necessary, all of the methods listed in the TLS Certificates document remain functional for the user of this template.

The Caddyfile of this template is intended to be used only inside containers and only in the environment generated by this template. In my opinion (and a couple of tests), the presence of the global skip_install_trust option for this repository does not change the way the resulting project interacts in any way. I would also not recommend using this global option outside the context of this template.

@francislavoie
Copy link

I would recommend not using -k and rather using --insecure to make it clear that it's bad to use. When you have -vk like that it's not obvious that there's a significant security downgrade happening.

@7-zete-7
Copy link
Contributor Author

7-zete-7 commented Jun 4, 2025

@francislavoie, I think this is a good idea. Created a PR to implement this change: #799

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing certutil package
3 participants