Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-94199: Remove ssl.match_hostname() function #94224

Merged
merged 1 commit into from Jun 25, 2022

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Jun 24, 2022

Remove the ssl.match_hostname() function. The ssl.match_hostname()
was deprecated in Python 3.7. OpenSSL performs hostname matching
since Python 3.7, Python no longer uses the ssl.match_hostname()
function.

Remove the ssl.match_hostname() function. The ssl.match_hostname()
was deprecated in Python 3.7. OpenSSL performs hostname matching
since Python 3.7, Python no longer uses the ssl.match_hostname()
function.
@vstinner vstinner marked this pull request as ready for review Jun 24, 2022
@vstinner
Copy link
Member Author

@vstinner vstinner commented Jun 24, 2022

Hum, it seems like this function deprecated since Python 3.7 is still widely used :-(

According to a code search on ssl.match_hostname, 37 projects of PyPI top 5000 projects use the deprecated function:

  • aliyun-python-sdk-core-2.13.36
  • ansible-core-2.13.1
  • backports.ssl_match_hostname-3.7.0.1
  • cassandra-driver-3.25.0
  • clvm_tools_rs-0.1.14
  • docker-5.0.3
  • docker-compose-1.29.2
  • docker-py-1.10.6
  • eth_abi-3.0.0
  • eth-account-0.6.1
  • eth-hash-0.3.2
  • eth-rlp-0.3.0
  • eth-utils-2.0.0
  • geventhttpclient-1.5.4
  • hexbytes-0.2.2
  • jedi-0.18.1
  • ldap3-2.9.1
  • newrelic-7.12.0.176
  • oci-2.72.0
  • pex-2.1.93
  • pip-22.1.2
  • pipenv-2022.6.7
  • pipreqs-0.4.11
  • pymongo-4.1.1
  • python-telegram-bot-13.12
  • pytype-2022.6.23
  • raven-6.10.0
  • rethinkdb-2.4.9
  • salt-3004.2
  • snowflake-connector-python-2.7.8
  • suds-1.1.1
  • suds-community-1.1.1
  • thrift-0.16.0
  • types-backports-0.1.3
  • types-urllib3-1.26.15
  • urllib3-1.26.9
  • xdis-6.0.4

I didn't check if the function is used on any Python version, or only on old Python versions, or maybe only on recent Python versions. The backports.ssl_match_hostname project is a backport of the ssl.match_hostname() function for Python 3.6 and older.

Searching for match_hostname finds 65 projects. For example, (distlib/compat.py)[https://github.com/pypa/distlib/blob/9b535c342eb7d11bed584e32e53f5d1c9303b034/distlib/compat.py#L92-L189] uses from ssl import match_hostname but has a fallback implementation for Python 3.6 and older.

The urllib3 module has its own implementation: urllib3/util/ssl_match_hostname.py.

cc @hugovk

@vstinner vstinner marked this pull request as draft Jun 24, 2022
@vstinner
Copy link
Member Author

@vstinner vstinner commented Jun 24, 2022

Hum, it seems like this function deprecated since Python 3.7 is still widely used :-(

For now, I mark the PR as a draft.

@tiran
Copy link
Member

@tiran tiran commented Jun 24, 2022

  • urllib3 does not use ssl.match_hostname. They have their own implementation.
  • pip contains a vendored copy of urllib3 and is not affected
  • python-telegram-bot package also contains a vendored copy of urllib3
  • Ansible has its own implementation
  • docker-py only needs it for Python < 3.5
  • backports.ssl_match_hostname is literally an old copy
  • ldap3 should just use check_hostname config flag
  • I don't care about crypto scam packages

@vstinner vstinner marked this pull request as ready for review Jun 24, 2022
@vstinner
Copy link
Member Author

@vstinner vstinner commented Jun 24, 2022

@tiran: I understand that you're fine with removing the function right now in Python 3.12, so I mark my PR as reviewable again :-)

tiran
tiran approved these changes Jun 25, 2022
@tiran tiran merged commit 944c7d8 into python:main Jun 25, 2022
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants