From cae1a1951b90f6f99a92ed0209169276c106c56d Mon Sep 17 00:00:00 2001 From: shreya1312 <42715355+shreya1312@users.noreply.github.com> Date: Fri, 1 Oct 2021 21:12:10 +0530 Subject: [PATCH] Set the ciphers before load_cert_chain Example: ``` self.socket = ssl.wrap_socket(socket.socket(self.address_family, self.socket_type), keyfile=keys, certfile=certs, server_side=True, ciphers="DEFAULT@SECLEVEL=1") ``` Gives the following exception - ``` File "ssl.py", line 1402, in wrap_socket context.load_cert_chain(certfile, keyfile) ssl.SSLError: [SSL: EE_KEY_TOO_SMALL] ee key too small (_ssl.c:4023) ``` --- Lib/ssl.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/ssl.py b/Lib/ssl.py index 207925166efa35..4fcbd47f43dbe5 100644 --- a/Lib/ssl.py +++ b/Lib/ssl.py @@ -1439,10 +1439,10 @@ def wrap_socket(sock, keyfile=None, certfile=None, context.verify_mode = cert_reqs if ca_certs: context.load_verify_locations(ca_certs) - if certfile: - context.load_cert_chain(certfile, keyfile) if ciphers: context.set_ciphers(ciphers) + if certfile: + context.load_cert_chain(certfile, keyfile) return context.wrap_socket( sock=sock, server_side=server_side, do_handshake_on_connect=do_handshake_on_connect,