apache: Generalize TLS config to use certificates only if available

- This allows TLS configuration to setup for domains that haven't yet
successfully obtained certificates yet.

Tests:

- Apply the patch on a production configuration and ensure that LE certificates
are properly used.

- With full pathset applied, on a test container, add a domain and ensure that
domain has its own site configuration and uses the snake-oil certificate.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2025-05-15 13:33:59 -07:00 committed by James Valleroy
parent 8401b08357
commit 0fa1dcf902
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808

View File

@ -16,8 +16,14 @@
SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1
# Automatically obtained certificates from Let's Encrypt
SSLCertificateFile /etc/letsencrypt/live/$domain/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/$domain/privkey.pem
<IfFile /etc/letsencrypt/live/$domain/privkey.pem>
SSLCertificateFile /etc/letsencrypt/live/$domain/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/$domain/privkey.pem
</IfFile>
<IfFile !/etc/letsencrypt/live/$domain/privkey.pem>
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
</IfFile>
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars