简体   繁体   English

如何获得 PyOpenSSL 的 NPN 支持?

[英]How do I get NPN support for PyOpenSSL?

I have an application that uses PyOpenSSL.我有一个使用 PyOpenSSL 的应用程序。 It depends upon the use of NPN.这取决于 NPN 的使用。 This used to work, but when I've re-created my virtual environment, the version of openssl PyOpenSSL is built against no longer supports NPN:这曾经可以工作,但是当我重新创建我的虚拟环境时,所构建的 openssl PyOpenSSL 版本不再支持 NPN:

Traceback (most recent call last):
  File "/tmp/sbpv/http2/proxy1/test_proxy.py", line 60, in <module>
    sys.exit(main())
  File "/tmp/sbpv/http2/proxy1/test_proxy.py", line 46, in main
    proxy_http2.configure_http2_server(args.listen_port, args.server_port, args.https_pem)
  File "/home/bneradt/repos/proxy-verifier/test/autests/gold_tests/autest-site/proxy_http2.py", line 188, in configure_http2_server
    context.set_npn_advertise_callback(npn_advertise_cb)
  File "/home/bneradt/.local/share/virtualenvs/autests-kCEHOjhw/lib/python3.8/site-packages/OpenSSL/SSL.py", line 650, in explode
    raise NotImplementedError(error)
NotImplementedError: NPN not available

The current version of PyOpenSSL is 19.1.0. PyOpenSSL 的当前版本是 19.1.0。 I've pulled back to PyOpenSSL 19.0.0 and 18.0.0, but they all seem to have been built against openssl1.1.1h:我已经退回到 PyOpenSSL 19.0.0 和 18.0.0,但它们似乎都是针对 openssl1.1.1h 构建的:

$ python -c "import OpenSSL; print(OpenSSL.version.__version__)"
18.0.0

$ python -c "import OpenSSL; print(OpenSSL.SSL.SSLeay_version(OpenSSL.SSL.SSLEAY_VERSION))"                                                                                                                                                
b'OpenSSL 1.1.1h  22 Sep 2020'

$ python -c "import OpenSSL; print(OpenSSL._util.lib.Cryptography_HAS_NEXTPROTONEG)"                                                                                                                                                          
0

Do the openssl versions PyOpenSSL is built against get updated with regularity such that my recent installs of these have different openssl versions? PyOpenSSL 的 openssl 版本是否会定期更新,以便我最近安装的这些版本具有不同的 openssl 版本? Or am I confused about how this works and PyOpenSSL is somehow using some local openssl version?或者我对它的工作原理感到困惑,而 PyOpenSSL 以某种方式使用了一些本地的 openssl 版本?

To be succinct, the question I'm asking is: how do I get a version of PyOpenSSL with NPN support?简而言之,我要问的问题是:如何获得支持 NPN 的 PyOpenSSL 版本?

PyOpenSSL does not ship with the built version of openssl. PyOpenSSL 不随 openssl 的构建版本一起提供。 It instead relies upon the cryptography Python module for that.相反,它依赖于密码学Python 模块。 If I pin the version of cryptography to 2.8 , then PyOpenSSL version 19.1.0 uses a version of openssl that has NPN support:如果我将密码学版本固定为 2.8 ,则 PyOpenSSL 版本 19.1.0 使用具有 NPN 支持的 openssl 版本:

$ python -c "import OpenSSL; print(OpenSSL._util.lib.Cryptography_HAS_NEXTPROTONEG)"
1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM