Change log level of CertificateError within match_hostname
MODIFY
src/urllib3/connection.py
src/urllib3/connection.py
@@ -429,7 +429,7 @@ def _match_hostname(cert, asserted_hostname):
try:
match_hostname(cert, asserted_hostname)
except CertificateError as e:
- log.error(
+ log.warning(
"Certificate did not match expected hostname: %s. " "Certificate: %s",
asserted_hostname,
cert,

MODIFY
test/test_connection.py
test/test_connection.py
@@ -32,7 +32,7 @@ class TestConnection(object):
cert = {"subjectAltName": [("DNS", "foo")]}
asserted_hostname = "bar"
try:
- with mock.patch("urllib3.connection.log.error") as mock_log:
+ with mock.patch("urllib3.connection.log.warning") as mock_log:
_match_hostname(cert, asserted_hostname)
except CertificateError as e:
assert "hostname 'bar' doesn't match 'foo'" in str(e)

Change log level of CertificateError within match_hostname (#1657)