Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions pywebsocket3/websocket_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,17 @@ def _create_sockets(self):
client_cert_ = ssl.CERT_REQUIRED
else:
client_cert_ = ssl.CERT_NONE
socket_ = ssl.wrap_socket(
socket_,
keyfile=server_options.private_key,
certfile=server_options.certificate,
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.

if server_options.certificate:
ssl_context.load_cert_chain(
certfile=server_options.certificate,
keyfile=server_options.private_key)
if server_options.tls_client_ca:
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?

self._sockets.append((socket_, addrinfo))

def server_bind(self):
Expand Down