Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tls: copy cert/key in cockpit-certificate-ensure
When starting up cockpit-tls, we have an existing helper called cockpit-certificate-ensure which is responsible for checking that we have a valid TLS certificate, and creating a self-signed one if not. This helper runs as root so that it can create the certificate, if needed. We want to enable cockpit-tls to read certificates which are not owned by the cockpit-ws user, which is useful in situations where we want to share certificates with other services. We can't do the normal "read as root and drop permissions after" trick because the environment that systemd launches cockpit-tls in never has the required permissions. cockpit-certificate-ensure does, however. Add a new "secret" --for-cockpit-tls option to cockpit-certificate-ensure which creates a new server/ subdirectory in the runtime directory of the service, and copies the certificate and key into that directory, to be read by cockpit-tls. This directory exists in a tmpfs, and the files created inside of it are owned by the cockpit-ws user and inaccessible to anyone else. Even still, we remove as soon as we're done reading them at startup. As an added bonus, we store symlinks into the same directory, which can be useful for determining the certificate that a running cockpit-tls is using.
- Loading branch information