Don't discard an explicit SSL context for HTTPS requests.
Review Request #15185 — Created July 21, 2026 and updated — Latest diff uploaded
CertificateVerificationHTTPSHandler.https_open()rebuiltself._context
from the Certificate Manager on every request, throwing away any context the
caller passed to the constructor.This broke the legacy
ssl_certfallback for hosting service accounts. When
a stored certificate does not match the server's hostname,
_build_ssl_context_from_ssl_cert()deliberately returns a context with that
certificate loaded andcheck_hostnameturned off. That context was replaced
with a strict one that had neither, so those connections would fail
verification.The handler now records whether the caller supplied a context, and rebuilds
the context only when it did not. Contexts that the handler built itself from
hostnameandportare still rebuilt from the request URL, so a redirect to
another server continues to use the right certificates.
- Added a test covering an explicit context surviving
https_open(), which
failed before this change. - Added a test covering a context built from the
hostnameandport
arguments. - Ran unit tests for
reviewboard.certsandreviewboard.hostingsvcs.