feat: support externally managed TLS via tls_external_cert_and_key option#860
feat: support externally managed TLS via tls_external_cert_and_key option#860
Conversation
70d3d07 to
8b64d97
Compare
8b64d97 to
a31ae26
Compare
a31ae26 to
2d31eb0
Compare
2d31eb0 to
edcf9bf
Compare
edcf9bf to
9258c8c
Compare
9258c8c to
e8288ea
Compare
e8288ea to
12b57c0
Compare
9cfc6bc to
48b738e
Compare
48b738e to
9a67be9
Compare
9a67be9 to
890fb3f
Compare
| ) | ||
|
|
||
|
|
||
| def get_tls_deployer(config, mail_domain): |
There was a problem hiding this comment.
High-level problem with this is that if you have a server with acmetool and want to reconfigure with external certificate, acmetool does not get uninstalled.
I think what we need is not selecting one deployer, but run all deployers with some option like enabled=... that tells the deployer if it should deploy or un-deploy acme or tls-cert-reload services.
There was a problem hiding this comment.
this is addressed in the separate #869 (the first commit, the second does some follow up refactoring)
all other review comments were fixed in the branch here.
| domain: staging-ipv4.testrun.org | ||
| secrets: | ||
| STAGING_SSH_KEY: ${{ secrets.STAGING_SSH_KEY }} | ||
|
|
There was a problem hiding this comment.
didn't want to further debug the workflow. Thorough TLS-mode testing is better done whne we have a more flexible provisioning of VPS and DNS for PRs.
| @@ -381,10 +381,12 @@ def iter_output(self, logcmd=""): | |||
| while 1: | |||
| line = self.popen.stdout.readline() | |||
| res = line.decode().strip().lower() | |||
| if res: | |||
| yield res | |||
| else: | |||
| if not res: | |||
| break | |||
| if ready is not None: | |||
| ready() | |||
| ready = None | |||
| yield res | |||
There was a problem hiding this comment.
this is a test fix on the side for a flaky test, took me a while to figure out. There are concurrency issues with getting log lines and triggering the send message. I think this is now reliable.
| server via SCP, runs ``cmdeploy run``, and then probes all TLS-enabled | ||
| ports (nginx, postfix, dovecot) to verify the certificate is actually | ||
| served. After probing, checks remote service logs for errors. | ||
|
|
There was a problem hiding this comment.
this test is only manually run, and partially machine generated.
j4n
left a comment
There was a problem hiding this comment.
Testing some more, it looks good, though there is one problem: the oneshot trigger reload fails on fresh deploys as services are not running yet.
| ) | ||
| # Trigger the oneshot service so services pick up the current cert. | ||
| # The path unit handles future changes via inotify. | ||
| systemd.service( |
There was a problem hiding this comment.
On a fresh deploy (or Docker container start), those services aren't running yet, so the reload fails. We can probably just remove this as dovecot/nginx read the cert on startup, and the .path watcher handles live cert changes via inotify.
|
One caveat turned up: inotify doesn't cross bind-mount boundaries and if certificates are modified outside of the container, the reload must be triggered explicitly. |
j4n
left a comment
There was a problem hiding this comment.
since its a simple remove of the system reload section, I guess I should still approve.
…tion Adds a new tls_external_cert_and_key config option for chatmail servers that manage their own TLS certificates (e.g. via an external ACME client or a load balancer). A systemd path unit (tls-cert-reload.path) watches the certificate file via inotify and automatically reloads dovecot and nginx when it changes. Postfix reads certs per TLS handshake so needs no reload. Also extracts openssl_selfsigned_args() so cert generation parameters are shared between SelfSignedTlsDeployer and the e2e test.
…ded if we can run it from work flows
Add tls_external_cert_and_key config option for chatmail servers that manage their own TLS certificates outside of ACME. When set, the deployer verifies the cert and key files exist on the server and installs a systemd path unit that watches the certificate via inotify — when it changes, dovecot and nginx are automatically reloaded (postfix reads certs per handshake so needs no reload). Includes unit tests, an e2e test script, docs, and a CI workflow.
this is based on the prior work of self-signed TLS certs in #855
PR replaces and closes #662