Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions cron/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ RUN apk update && \

WORKDIR /workdir

COPY lets-encrypt-r4.pem /workdir/lets-encrypt-r4.pem
COPY bundle_certs.sh /etc/periodic/daily/bundle_certs

RUN chmod +x /etc/periodic/daily/bundle_certs
COPY bundle_certs.sh /usr/local/bin/bundle_certs
RUN chmod +x /usr/local/bin/bundle_certs

VOLUME /pem

CMD ["crond", "-f", "-l", "0"]
# Run bundle once at boot (populate pem_certs before Haraka's first STARTTLS),
# then keep the daily crond for renewals. Caddy's fullchain is copied verbatim.
CMD ["sh", "-c", "bundle_certs; exec crond -f -l 0"]
19 changes: 14 additions & 5 deletions cron/bundle_certs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,18 @@ set -e

if [ -z "$EMAIL_DOMAIN" ]; then echo "EMAIL_DOMAIN is not set"; exit 1; fi

cd /workdir
CERT_DIR="/caddy/certificates/acme-v02.api.letsencrypt.org-directory/$EMAIL_DOMAIN"
LEAF="$CERT_DIR/${EMAIL_DOMAIN}.crt"
KEY="$CERT_DIR/${EMAIL_DOMAIN}.key"

if [ ! -s "$LEAF" ] || [ ! -s "$KEY" ]; then
echo "Caddy cert not ready yet ($LEAF); skipping"
exit 0
fi

echo "Copying Caddy certs to Haraka..."
cd "/caddy/certificates/acme-v02.api.letsencrypt.org-directory/$EMAIL_DOMAIN"
cp "${EMAIL_DOMAIN}.key" /pem/tls_key.pem
cat "${EMAIL_DOMAIN}.crt" /workdir/lets-encrypt-r4.pem > /pem/tls_cert.pem
echo "Copied Caddy certs to Haraka."
# Caddy's {domain}.crt is already the full chain (leaf + intermediates).
# Copy it verbatim — appending a separate intermediate would duplicate/break the chain.
cp "$KEY" /pem/tls_key.pem
cp "$LEAF" /pem/tls_cert.pem
echo "Copied Caddy certs to Haraka."
30 changes: 0 additions & 30 deletions cron/lets-encrypt-r4.pem

This file was deleted.

5 changes: 5 additions & 0 deletions haraka/haraka_config/config/tls.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
key=certs/tls_key.pem
cert=certs/tls_cert.pem

; Disable client-initiated TLS renegotiation (DoS via repeated handshakes).
; Value is crypto.constants.SSL_OP_NO_RENEGOTIATION (0x40000000), passed
; through to tls.createSecureContext as secureOptions by Haraka's tls_socket.
secureOptions=1073741824
Loading