簡體   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