Skip to content

Fix SSL certificate lookup for HTTPS URLs with custom ports#3665

Open
dicnunz wants to merge 1 commit into
bluewave-labs:developfrom
dicnunz:fix-ssl-expiry-nonstandard-port-3646
Open

Fix SSL certificate lookup for HTTPS URLs with custom ports#3665
dicnunz wants to merge 1 commit into
bluewave-labs:developfrom
dicnunz:fix-ssl-expiry-nonstandard-port-3646

Conversation

@dicnunz
Copy link
Copy Markdown

@dicnunz dicnunz commented May 20, 2026

Describe your changes

fetchMonitorCertificate now passes the configured HTTPS port to ssl-checker when a monitor URL includes a non-standard port, e.g. https://checkmate.example.org:54321/status. It also still supports the existing monitor.port field and keeps the previous default behavior when no port is configured.

Added a focused regression test for:

  • URL port parsed from an HTTPS monitor URL
  • monitor.port fallback
  • no-port default behavior
  • missing certificate expiry error handling

Write 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.

  • (Do not skip this or your PR will be closed) I deployed the application locally. Server build completed; this is a server utility fix with no UI path changed.
  • (Do not skip this or your PR will be closed) I have performed a self-reviewing and testing of my code.
  • I have included the issue # in the PR.
  • I have added i18n support to visible strings. N/A, no visible strings added.
  • I have not included any files that are not related to my pull request, including package-lock and package-json if dependencies have not changed.
  • I didn't use any hardcoded values.
  • I made sure font sizes, color choices etc are all referenced from the theme. N/A, no UI/CSS changes.
  • My PR is granular and targeted to one specific feature.
  • I ran npm run format in server and client directories, which automatically formats your code. Touched server files pass Prettier check; no client files changed.
  • I took a screenshot or a video and attached to this PR if there is a UI change. N/A, no UI change.

Verification:

  • npm test -- --runTestsByPath test/unit/controllers/controllerUtils.test.ts --coverage=false
  • npm run build
  • npx prettier --check src/controllers/controllerUtils.ts test/unit/controllers/controllerUtils.test.ts
  • npx 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

Copy link
Copy Markdown
Collaborator

@ajhollid ajhollid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member

@Br0wnHammer Br0wnHammer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SSL/TLS certificate expiry not checked on non standard https port

3 participants