Skip to content

fix(security): skip with clear diagnostic on TLS cert verify failure#210

Merged
ian-flores merged 6 commits intomainfrom
fix-security-tls-diagnostics
Apr 22, 2026
Merged

fix(security): skip with clear diagnostic on TLS cert verify failure#210
ian-flores merged 6 commits intomainfrom
fix-security-tls-diagnostics

Conversation

@ian-flores
Copy link
Copy Markdown
Collaborator

@ian-flores ian-flores commented Apr 21, 2026

Summary

Issue #175 reported that test_tls_12_or_higher_is_enforced_for_product failed with an opaque SSL: CERTIFICATE_VERIFY_FAILED error behind an SSL-terminating proxy. That specific test lives in src/vip_tests/cross_product/test_ssl.py and was already fixed by #198 (commit c057b80), which classifies handshake outcomes and surfaces a trust-bundle hint when verification fails.

This PR applies the same classification to the sibling inspect_headers step in src/vip_tests/security/test_https.py, which was catching httpx.ConnectError and reporting "connection refused" for all failure modes — including cert-verify failures that httpx wraps inside ConnectError. The test now detects ssl.SSLCertVerificationError (via __cause__ and a CERTIFICATE_VERIFY_FAILED substring fallback) and skips with a clear message pointing to SSL_CERT_FILE and common CA bundle paths (Debian/Ubuntu, RHEL, and python -m certifi).

Test plan

  • Ruff: just check passes
  • Selftests: uv run pytest selftests/ passes (303/303 locally)
  • Product tests against ganso01-staging Connect:
    • With SSL_CERT_FILE pointed at a self-signed CA that doesn't trust the ACM cert, test_product_does_not_expose_sensitive_headers[Connect] skips with the new diagnostic: "Could not verify TLS certificate for Connect at ...: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate ... This is a certificate-trust issue on the test runner, not a server security finding. If the server uses a valid public certificate (e.g. behind an AWS ALB with an ACM cert), set SSL_CERT_FILE to a CA bundle that includes public roots: /etc/ssl/certs/ca-certificates.crt on Debian/Ubuntu, /etc/pki/tls/certs/ca-bundle.crt on RHEL, or the path produced by python -m certifi."
    • With SSL_CERT_FILE unset (valid default CA bundle), the same test PASSES against Connect — the cert-verify branch does not swallow legitimate test runs

Fixes #175

inspect_headers now distinguishes ssl.SSLCertVerificationError (wrapped
by httpx.ConnectError) from plain connection refusals.  A cert-verify
failure is a trust-bundle issue on the test runner (common when the
server is behind an AWS ALB with an ACM certificate), not a server
security finding — skip with guidance pointing to SSL_CERT_FILE and
common CA bundle paths, mirroring the pattern applied to test_ssl.py
in #198.

Fixes #175
Copilot AI review requested due to automatic review settings April 21, 2026 22:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Aligns inspect_headers in the security HTTPS tests with the TLS handshake classification added in #198, so certificate verification failures behind SSL-terminating proxies are skipped with actionable CA-bundle guidance instead of being reported as “connection refused”.

Changes:

  • Add ssl import and classify httpx.ConnectError cases caused by TLS certificate verification failures.
  • Skip (with a clear diagnostic pointing to SSL_CERT_FILE and common CA bundle locations) when cert verification fails; otherwise keep failing with the existing “connection refused” guidance.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/vip_tests/security/test_https.py Outdated
Comment on lines +80 to +82
# guidance rather than failing as "connection refused". See
# test_ssl.py (commit c057b80 / PR #198) for the same
# classification applied to the TLS-version test.
Comment thread src/vip_tests/security/test_https.py Outdated
Comment on lines +88 to +92
f"Could not verify TLS certificate for {product} at {pc.url}: {exc}. "
"This is a certificate-trust issue on the test runner, not a "
"server security finding. If the server uses a valid public "
"certificate (e.g. behind an AWS ALB with an ACM cert), set "
"SSL_CERT_FILE to a CA bundle that includes public roots: "
Remove commit hash/PR number from inline comment and fix double spaces
in the TLS skip message for cleaner, more durable source text.
Move import re to module scope, and improve the inline comment to use the
full path to test_ssl.py and explain why that test raises while this one skips.
Document why the CERTIFICATE_VERIFY_FAILED string fallback is needed
alongside the isinstance check, clarifying the transport-specific case
where httpx does not populate __cause__.
@ian-flores ian-flores marked this pull request as ready for review April 22, 2026 14:14
@ian-flores ian-flores merged commit 0da623e into main Apr 22, 2026
21 checks passed
@ian-flores ian-flores deleted the fix-security-tls-diagnostics branch April 22, 2026 16:19
@github-actions
Copy link
Copy Markdown

PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-04-22 16:20 UTC

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.

fix(security): TLS verification test fails with unclear error behind SSL-terminating proxy

2 participants