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

Find a replacement for deprecated ssl.match_hostname #368

Closed
jlaine opened this issue Apr 2, 2023 · 2 comments
Closed

Find a replacement for deprecated ssl.match_hostname #368

jlaine opened this issue Apr 2, 2023 · 2 comments

Comments

@jlaine
Copy link
Contributor

jlaine commented Apr 2, 2023

When connecting to a server, we rely on the standard library's ssl.matchhostname method to check the certificate presented by the server is valid for the hostname we connected to. Howver this method has been deprecated since Python 3.7 so we need to find a suitable replacement.

So far I have found:

  • urllib3 vendors this method into its code. This does seem like a great option as it puts the burden of maintaining a critical piece of code on us.
  • OpenSSL has an X509_check_host method. AFAICT this is not accessible from pyOpenSSL.
@GalaxySnail
Copy link
Contributor

I found service-identity which is mentioned in trio's documentation, it may be helpful.

@jlaine
Copy link
Contributor Author

jlaine commented Jul 4, 2023

I found service-identity which is mentioned in trio's documentation, it may be helpful.

Thank you very much, this looks like exactly what we want!

jlaine added a commit to jlaine/aioquic that referenced this issue Jul 5, 2023
The standard libraries's `ssl.match_hostname` method was marked as
deprecated in Python 3.10. Rather than implementing this critical piece
of code ourselves, make use of the Python Cryptographic Authority's
`service-identity` package.

One notable behaviour change is that validation is performed *only*
against the `subjectAltName` extension instead of the `commonName`. This
is the same behaviour as web browsers use.
jlaine added a commit to jlaine/aioquic that referenced this issue Jul 5, 2023
The standard libraries's `ssl.match_hostname` method was marked as
deprecated in Python 3.10. Rather than implementing this critical piece
of code ourselves, make use of the Python Cryptographic Authority's
`service-identity` package.

One notable behaviour change is that validation is performed *only*
against the `subjectAltName` extension instead of the `commonName`. This
is the same behaviour as web browsers use.
jlaine added a commit to jlaine/aioquic that referenced this issue Jul 5, 2023
The standard libraries's `ssl.match_hostname` method was marked as
deprecated in Python 3.10. Rather than implementing this critical piece
of code ourselves, make use of the Python Cryptographic Authority's
`service-identity` package.

One notable behaviour change is that validation is performed *only*
against the `subjectAltName` extension instead of the `commonName`. This
is the same behaviour as web browsers use.
@jlaine jlaine closed this as completed in b097478 Jul 5, 2023
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 a pull request may close this issue.

2 participants