Skip to content

Conversation

zaurask
Copy link

@zaurask zaurask commented Mar 28, 2024

The ssl.wrap_socket function was removed in 3.12. This PR migrates ssl.wrap_socket to SSLContext.wrap_socket by recreating the logic already used internally by ssl.wrap_socket when called from pywebsocket3.

Tested by successfully running WPT locally.

Fixes #38.

ca_certs=server_options.tls_client_ca,
cert_reqs=client_cert_)

ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we should use ssl.PROTOCOL_TLS_SERVER if we are on Python >= 3.6.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far the defaults were used since they were not set when calling ssl.wrap_socket(): server_side=False and ssl_version=PROTOCOL_TLS. Since I am not sure about the implications I used those defaults. For PROTOCOL_TLS it looks like it is deprecated since version 3.10, so going for PROTOCOL_TLS_SERVER seems to be the right choice.

ssl_context.load_verify_locations(
server_options.tls_client_ca)
ssl_context.verify_mode = client_cert_
socket_ = ssl_context.wrap_socket(socket_)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need server_side=True?

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.

ssl.wrap_socket() was removed in Python 3.12

2 participants