Fix SSL certificate lookup for HTTPS URLs with custom ports#3665
Fix SSL certificate lookup for HTTPS URLs with custom ports#3665dicnunz wants to merge 1 commit into
Conversation
ajhollid
left a comment
There was a problem hiding this comment.
No real problems with this PR, but a small design decision that needs to be considered.
Thanks for your work on the project!
| const hostname = monitorUrl.hostname; | ||
| const cert = await checker(hostname); | ||
| const urlPort = monitorUrl.port ? Number(monitorUrl.port) : undefined; | ||
| const port = monitor.port ?? urlPort; |
There was a problem hiding this comment.
I think this should probably be inverted, an explicit port set in the URL should probably take precedence over the monitor.port field.
This is a design decision, but I think the visually prominent port in the monitor URL should take precedence over a field that is not readily visible in the monitor config 🤔
Consider the case where a user has set their url to be https://www.myurl.com:52345/health and accidentally set port 443 on the monitor config. We will silently be checking on 443 while the user would be left wondering why port 52345 as declared in their URL is not responding.
Again a design decision, but I think probably the right call here.
Describe your changes
fetchMonitorCertificatenow passes the configured HTTPS port tossl-checkerwhen a monitor URL includes a non-standard port, e.g.https://checkmate.example.org:54321/status. It also still supports the existingmonitor.portfield and keeps the previous default behavior when no port is configured.Added a focused regression test for:
monitor.portfallbackWrite your issue number after "Fixes "
Fixes #3646
Please ensure all items are checked off before requesting a review. "Checked off" means you need to add an "x" character between brackets so they turn into checkmarks.
npm run formatin server and client directories, which automatically formats your code. Touched server files pass Prettier check; no client files changed.Verification:
npm test -- --runTestsByPath test/unit/controllers/controllerUtils.test.ts --coverage=falsenpm run buildnpx prettier --check src/controllers/controllerUtils.ts test/unit/controllers/controllerUtils.test.tsnpx eslint src/controllers/controllerUtils.ts test/unit/controllers/controllerUtils.test.ts(0 errors; test file is ignored by the repo ESLint ignore pattern)Optional: if this saves you time and you are open to a small direct-fix payment, I use this checkout: https://nicdunz.gumroad.com/l/tiny-codex-teardown-direct?wanted=true