繁体   English   中英

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

[英]How to upgrade openssl version and link it to python 3.6.5

我的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链接应自动处理。

暂无
暂无

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

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