fix(ssl): validate custom certificate and key before install#492
Open
mrrobot47 wants to merge 1 commit into
Open
fix(ssl): validate custom certificate and key before install#492mrrobot47 wants to merge 1 commit into
mrrobot47 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
validate_site_custom_ssl()only checked that the--ssl-key/--ssl-crtfiles exist;custom_site_ssl()then copied them intoservices/nginx-proxy/certs/with no validation. A malformed PEM, or a certificate and key that don't match, silently breaks nginx-proxy on the next reload.Fix
Add
assert_valid_cert_key_pair()(called fromvalidate_site_custom_ssl()before the paths are stored): parse the certificate (openssl_x509_parse), parse the key (openssl_pkey_get_private), and verify they match (openssl_x509_check_private_key). An unparseable certificate, an invalid key, or a key/cert mismatch are hard errors. An expired or near-expiry (< 30 days) certificate is a loud warning (not a block), so legitimate clone/restore flows that re-supply an existing certificate still proceed.Testing
Manual: mismatched key/crt → error; malformed PEM → error; expired cert → warning (proceeds); valid matching pair → installs. The validation helper is pure and unit-testable.