backports.ssl_match_hostname
The ssl.match_hostname() function from Python 3.5
What it is and what it does
This package backports the ssl.match_hostname() function from Python 3.7 to earlier Python versions. It implements RFC 2818 (and later RFC 6125) compliant hostname matching for SSL/TLS certificates, ensuring that the hostname in a server's certificate matches the hostname you are connecting to—a critical security check for encrypted connections.
The function was introduced in Python 3.2 and has been part of the standard library ever since. This backport was designed for projects supporting older Python versions that lacked the function. However, the package has been abandoned since 2019 and is now obsolete for any project running Python 3.2 or later, which includes all modern Python versions.
Use it for:
- Validating SSL certificates in legacy Python 2.x applications that need hostname verification before Python 3.2 was available.
- Ensuring secure HTTPS connections in older Python codebases by checking certificate hostnames match the target server.
- Porting Python 3.x code to run on Python 2.4–2.7 while maintaining SSL security checks.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides the ssl.match_hostname() function for validating that a server's SSL certificate hostname matches the hostname being connected to, backported from Python 3.7 for use on earlier Python versions.
No. This package is abandoned (last release 2019-01-12) and unnecessary for any modern Python project. Python 3.2+ includes match_hostname() in the standard library; Python 2.x is end-of-life. Install only if maintaining legacy Python 2.x code that cannot be upgraded—otherwise use the built-in ssl.match_hostname().
Install
backports-ssl-match-hostname on PyPI
pip
pip install backports-ssl-match-hostnameuv
uv add backports-ssl-match-hostnamepoetry
poetry add backports-ssl-match-hostnameInstalling backports.ssl_match_hostname
Before you install
The package is abandoned as of 2019-01-12 and has not been updated in 2771 days. Modern Python versions (3.2+) include match_hostname() in the standard library, making this backport unnecessary for current projects. High install friction due to its age and obsolescence.
License in practice
Licensed under the Python Software Foundation License (permissive), which poses no restrictions on use or redistribution.
Quickstart
from backports.ssl_match_hostname import match_hostname, CertificateError
import ssl
sslsock = ssl.wrap_socket(sock, ssl_version=ssl.PROTOCOL_SSLv23,
cert_reqs=ssl.CERT_REQUIRED, ca_certs=...)
try:
match_hostname(sslsock.getpeercert(), hostname)
except CertificateError:
pass
Only needed for Python versions earlier than 3.2; modern Python includes match_hostname() in the standard library ssl module.
Verify before relying
- Whether this package is still maintained or if it has been formally deprecated in favor of the standard library.
- Whether any security patches have been applied since the last release in 2019.
Package facts
| License | Python Software Foundation License (permissive) |
| Python support | not specified |
| Install friction | high — source build required |
| Runtime dependencies | none |
| Maintenance | abandoned — 2,771 days since the last release |
| First released | |
| Downloads | 642,635/month — #5,611 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: backports.ssl_match_hostname-3.7.0.1.tar.gz
Tags
More Cryptography packages
Certifi provides Mozilla's curated collection…
copyleft · top 100 on PyPI
cryptographycryptography provides cryptographic recipes and…
permissive · top 100 on PyPI
rsaPure-Python RSA encryption, decryption,…
permissive · top 1,000 on PyPI
pyOpenSSLpyOpenSSL wraps OpenSSL's SSL/TLS functionality…
permissive · top 1,000 on PyPI
azure-identityProvides Microsoft Entra ID token-based…
unclear · top 1,000 on PyPI
PyNaClPyNaCl provides Python bindings to libsodium…
permissive · top 1,000 on PyPI
idna_sslPatches Python's ssl.match_hostname to support…
permissive · top 15,000 on PyPI
service-identityVerifies that cryptography or pyOpenSSL…
permissive · top 5,000 on PyPI
backports.sslProvides the Python 3.4 ssl module API on older…
permissive · top 15,000 on PyPI
ipaddressProvides IPv4 and IPv6 address manipulation for…
permissive · top 5,000 on PyPI
secure-smtplibProvides secure SMTP subclasses with TLS/SSL…
unclear · top 15,000 on PyPI
hstspreloadProvides a single function to check whether a…
permissive · top 15,000 on PyPI
fqdnValidates fully-qualified domain names (FQDNs)…
copyleft · top 1,000 on PyPI
python-certifi-win32Patches certifi at runtime to include…
permissive · top 15,000 on PyPI
pip-system-certsAutomatically configures Python to use the…
permissive · top 5,000 on PyPI