gpt4 book ai didi

python - 如何升级openssl版本并将其链接到python 3.6.5

转载 作者:太空宇宙 更新时间:2023-11-03 14:33:18 59 4
gpt4 key购买 nike

我的 Ubuntu 机器上有多个版本的 python。默认值为 2.7。但是,我可以通过转到以下特定路径来设法运行 python 3.6:

/usr/local/bin/code/tls-client

我需要在我的 python 代码中使用 openSSL 库。我想运行特定版本:1.1.0。我尝试使用 pip install openssl 然后检查版本是否已更新,但事实并非如此。

python3
Python 3.6.5 (default, May 3 2018, 10:08:28)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
>>> ssl.OPENSSL_VERSION
'OpenSSL 1.0.2g 1 Mar 2016'

如何将 python 3.6.5 链接到特定版本的 openSSL(比如 OpenSSL 1.1.0)?甚至 1.1.1(如果可能)?

编辑:按照答案建议从源代码编译后,我检查了版本,这就是我得到的:

/usr/local/bin/openssl-1.1.0h$ openssl version -a
OpenSSL 1.0.2g 1 Mar 2016
built on: reproducible build, date unspecified
platform: debian-amd64
options: bn(64,64) rc4(16x,int) des(idx,cisc,16,int) blowfish(idx)
compiler: cc -I. -I.. -I../include -fPIC -DOPENSSL_PIC -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -m64 -DL_ENDIAN -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -Wl,-Bsymbolic-functions -Wl,-z,relro -Wa,--noexecstack -Wall -DMD32_REG_T=int -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DECP_NISTZ256_ASM
OPENSSLDIR: "/usr/lib/ssl"

最佳答案

假设您还没有更新到 OpenSSL 的最新稳定版本(来自 bash 控制台):

$ sudo apt update && sudo apt upgrade openssl

如果没有安装您期望的版本(通过执行 openssl version -a 检查),然后尝试编译并手动安装:

wget https://www.openssl.org/source/openssl-1.1.0h.tar.gz
tar xzvf openssl-1.1.0h.tar.gz
cd openssl-1.1.0h
./config -Wl,--enable-new-dtags,-rpath,'$(LIBRPATH)'
make
make install

openssl version -a

应该将 OpenSSL 更新到版本 1.1.0h — 应该自动处理链接。

关于python - 如何升级openssl版本并将其链接到python 3.6.5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50663229/

59 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com