- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
caddy trust
command to manually trigger the root CA trust setup
#3204
Comments
Additional feature request: The
|
Okay, after misunderstanding this first I think I get it now. We can probably do this... however, the details of sudo and stuff still need to be implemented by the upstream library: https://github.com/FiloSottile/mkcert |
@lukasbestle Alrighty, I have implemented this in 244b839 - please try it out! |
@mholt Thanks for the fast implementation! It generally works well, there's just one minor issue: If I run it with So either the PKI generation should happen with user permissions or |
That's a tricky problem. When running as root with sudo, it's not completely reliable, but you can use the SUDO_UID and SUDO_GID env vars, but those can be overridden before the program is run. |
@francislavoie Yep, that's what I would suggest as well. The env vars cannot be overridden when Caddy is really called with |
If running Caddy as root, this is expected. I would run Caddy can't install root certificates without root privileges. |
Caddy can't install root certificates without root privileges, but it can generate them without root privileges. What I suggest is that Caddy could ensure itself that all files it creates are created with the proper permissions and owners. The user of Caddy doesn't know from the outside which files Caddy has created, so they can also not manually I personally am fine with manually |
Hmm, I see what you mean, but what is the safe alternative? If |
That's the issue – if I run The A possible solution could be to detect the |
Isn't it risky to trust the SUDO_UID variable, since it can be set to anything? In any case, this is a pretty nuanced/involved feature request (privilege deescalation in Go is tricky) so I'll probably shelve it for now and just recommend using chown explicitly. A lot less magic involved and a lot less head scratching when you run something as root and it ends up making files owned by non-root. |
I'd say if Caddy is run by root, you can trust everything as So maybe it's indeed better to leave it as is for now. The current implementation already helps a lot, thanks for that! 👍 |
Great, thanks for the consideration! |
I'm currently working on an Ansible role to automate the installation and setup of a Caddy-based local development setup. I need a way to manually trigger the root CA setup to ensure that Caddy can afterwards be run as a system service without having to enter a password anywhere.
I propose a new command
caddy trust
that could be run withsudo
to do the following without user interaction:The text was updated successfully, but these errors were encountered: