fix(ssl): copy and validate custom certs on site update#489
Open
mrrobot47 wants to merge 1 commit into
Open
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
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. Re-running this command is now also the way to replace an expiring custom cert.Missing/invalid
--ssl-key/--ssl-crtfails fast (inside the existing try/catch, before$site->save()), so there is no partial DB-vs-cert state.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.