G
G
gd1xza2021-05-22 08:41:00
Python
gd1xza, 2021-05-22 08:41:00

OpenSSL python ssl functions not working?

The code:

import ssl,socket

print(ssl.OPENSSL_VERSION)

s = socket.socket(2,1)
s.connect(("g.co", 443))

ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
ctx.set_ciphers("ECDHE-RSA-AES256-GCM-SHA384")
ctx.verify_mode = ssl.CERT_REQUIRED
ctx.check_hostname = True
ctx.load_default_certs()
ctx.set_npn_protocols(['h2-14'])

c = ctx.wrap_socket(s, server_hostname="g.co",do_handshake_on_connect=False)
c.do_handshake()

print(c.selected_npn_protocol())


I get an error from calling set_npn_protocols():
NotImplementedError: The NPN extension requires OpenSSL 1.0.1 or later.

At the very beginning of the program, there is an output of the openssl version:
OpenSSL 1.1.1g 21 Apr 2020

So why doesn't it work

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alexbprofit, 2021-05-22
@alexbprofit

pip install --upgrade pyopenssl

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question