Skip to content

check_http: add opt-in TLS certificate verification - #505

Open
inqrphl wants to merge 1 commit into
mainfrom
check-http-security-fixes-1
Open

inqrphl wants to merge 1 commit into
mainfrom
check-http-security-fixes-1

Conversation

@inqrphl

@inqrphl inqrphl commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

AI-generated PR: This pull request was created with AI assistance. Please review the changes before merging.

Problem

check_http did not verify the target TLS certificate. This matches monitoring-plugins check_http and remains the default for compatibility, so checks against self-signed or private-CA targets keep working.

When a check sends credentials with -a, -k, or -P, an unverified peer can receive them and can return a forged result. This is the risk described in security audit finding F-03.

Change

  • Add --verify-cert to verify the certificate chain and hostname against the system roots.
  • Add --ca-cert=<file> to verify against a PEM CA file. It replaces the system roots and also enables --verify-cert, matching check_curl from monitoring-plugins.
  • Keep the default: no certificate verification.
  • -C still checks expiry and optional names. It now verifies the chain and hostname when verification is enabled.
  • A missing or invalid CA file returns UNKNOWN instead of silently skipping verification.
  • Document the default and the difference from -C in the help text and the generated docs.

Behavior

Arguments Chain Host name
default not checked not checked
--verify-cert system roots checked
--ca-cert FILE FILE checked
-C alone not checked only with --check-cn/--check-san
-C --verify-cert system roots checked

Existing checks are unchanged unless one of the new flags is used.

Testing

  • New TestHTTPSPeerVerification covers the default, --verify-cert, --ca-cert, certificate mode, and a missing CA file.
  • make fmt
  • make golangci (linux, darwin, freebsd, windows)
  • make test
  • go test -race -short ./pkg/check_http
  • make docs

check_http did not verify the target certificate. This matches
monitoring-plugins check_http and remains the default, so checks for
self-signed and private-CA targets keep working.

Add --verify-cert to verify the certificate chain and hostname against
the system roots. Add --ca-cert to verify against a PEM file instead,
which also enables --verify-cert. Checks that send credentials with -a,
-k, or -P can now authenticate the peer.

Explain the default and the difference from the -C expiry check in the
help text and the generated docs.
@inqrphl
inqrphl requested a review from sni November 26, 2026 13:25
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.

1 participant