The `idna-ssl` library provides a patch for Python's standard `ssl.match_hostname` function to correctly support Unicode (IDNA) domains. It aims to offer backward compatibility for older Python versions (pre-3.7) where `ssl.match_hostname` had significant issues with internationalized domain names, and to address lingering IDNA2008 compliance problems even in later Python releases. The library's current version is 1.1.0, released in July 2018. The project's GitHub repository has been archived and is read-only since October 2020, indicating it is no longer actively maintained.
pip install idna-sslVerified import paths — ran on the pinned version, not inferred.
The `patch_match_hostname()` function needs to be imported and called early in your application's lifecycle to apply the necessary fix globally. The example demonstrates its use with `aiohttp` to access a Unicode domain, which would otherwise fail hostname verification on affected Python versions.
Thoroughly test your application's SSL/TLS interactions after applying the patch. Inspect call stacks if unexpected SSL errors occur to identify potential conflicts.
Evaluate if the specific IDNA-related `ssl.match_hostname` issue you are facing is resolved in newer Python versions (3.7+ improved IDNA handling significantly). If possible, consider upgrading Python or finding alternative solutions for IDNA domain validation, such as explicitly using the `idna` library for encoding/decoding before passing to standard `ssl` functions where applicable.
Understand the specific IDNA specification (IDNA2003 vs. IDNA2008, UTS #46) relevant to your use case. If strict IDNA2008 compliance is critical for `ssl.match_hostname`, this library might still be necessary, but consider the 'abandoned' status.
Stay informed about Python's `ssl` module updates and security advisories. If patching, consider whether the patch might interfere with future security enhancements or changes in behavior in `ssl.match_hostname`.