Add and use a new HTTPS handler, error reporting, and urlopen wrapper.
Review Request #14943 — Created March 18, 2026 and updated — Latest diff uploaded
This introduces
reviewboard.certs.http, which contains a URL opener,
CertificateVerificationHTTPSHandler. This takes care of generating a
suitable SSL context based on the certificate manager, and handles the
conversion of SSL/TLS errors to our own exceptions.If an
SSLErroris raised, it will be converted into a
CertificateVerificationError, complete with aCertificateinstance
fetched from the server (asSSLErrordoesn't contain this). This means
individual call sites don't have to convert SSL errors anymore.A
urlopen()method in the same module is available, which can be used
as a direct replacement forurllib.request.urlopen(). If communicating
over HTTPS, this will make use of our new handler. Otherwise, it's the
exact same as calling the originalurlopen().All
urlopen()call sites have been updated to use this. They were
recently updated to usebuild_urlopen_kwargs(), but that's no longer
required. In fact, this method is now deprecated in favor of the new
handler.The hosting service HTTP support makes use of the new handler directly,
allowing it to leverage the central context building and error handling.Unless a legacy
UnverifiedCertificateErroris explicitly returned by a
hosting service or SCMTool, all call sites will now use the modern
CertificateVerificationError.
All unit tests pass.
Manually tried adding repositories using bare SCMTools and hosting
services, verifying I received the cert verification banner each time.
Tested this with a variety of https://badssl.com endpoints.Verified that trusting the cert created a stored cert entry and that
further access worked.