Conversation
… key Only the existence of --ssl-key/--ssl-crt was checked, so a mismatched pair or a non-PEM file was copied into nginx-proxy/certs and the command reported success. nginx-proxy then fails `nginx -t` for the whole config, which blocks proxy reloads for every site and would stop the proxy from starting after a restart. Validate the pair with openssl_x509_check_private_key() before anything is copied.
Symfony Filesystem::copy() opens the target for writing before reading the source, so passing the files already in nginx-proxy/certs (the natural way to re-enable custom SSL after --ssl=off) left an empty key and cert while the command reported success. Skip the copy when the source already is the destination.
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
ee site update --ssl=customset the DB flag and enabled HTTPS but never copied the certificate files.update_ssl()callswww_ssl_wrapper(), which explicitly skips all cert work forcustom, and the cert-copy helpers (validate_site_custom_ssl()/custom_site_ssl()) were only invoked from the create path. Result: HTTPS turned on with no certs innginx-proxy/certs/, so the site served a wrong/default cert. This is also the pathCloner.phprecommends after cloning a custom-SSL site, so that guidance led to a broken state too.Fix
In
update_ssl(), when the target type iscustom, mirror the create path: validate--ssl-key/--ssl-crtviavalidate_site_custom_ssl()and copy them viacustom_site_ssl()beforewww_ssl_wrapper(). Also documents the--ssl-key/--ssl-crtflags and adds an example. To replace an expiring custom cert, disable SSL and re-enable it with the new pair (ee site update <site> --ssl=off, thenee site update <site> --ssl=custom --ssl-key=... --ssl-crt=...); running--ssl=customon a site that already has SSL still stops with "SSL is already enabled".Missing or nonexistent
--ssl-key/--ssl-crt, a certificate that isn't valid PEM, or a key that doesn't match the certificate fails fast (inside the existing try/catch, before$site->save()), so nothing is copied and there is no partial DB-vs-cert state. Re-enabling with the files already innginx-proxy/certs/as the source no longer truncates them.Known limitation
If the post-copy bring-up (
www_ssl_wrapper) throws, the copied cert files are left in place (no rollback); re-running the command overwrites them. The create path'scatch_cleanunwind is not mirrored here — a follow-up could unify the two cert paths.Testing
Manual: create a non-SSL site, generate a self-signed key/crt, run
ee site update <site> --ssl=custom --ssl-key=... --ssl-crt=..., and assertnginx-proxy/certs/<site>.key|.crtexist and the served cert matches.Tested on Ubuntu 26.04 with EasyEngine 4.12.0: valid pair with relative paths (served cert matches, HTTP redirects to HTTPS), missing flags, nonexistent path and mismatched pair (rejected, nothing copied), same-path re-enable, the off-then-custom replacement flow, and
create --ssl=customregressions.Merge note
#492 adds
assert_valid_cert_key_pair()to the same function, which also checks the key/cert match. Once both are merged, this PR'sopenssl_x509_check_private_key()check is redundant; whichever merges second should drop the duplicate.