如何在Ubuntu中将OpenSSL从1.0.2g升级到1.1.0g并让python识别新的OpenSSL

时间:2018-07-27 15:18:32

标签: ssl openssl ubuntu-16.04 tls1.2 pyopenssl

我有Ubuntu 16.04。它有OpenSSL 1.0.2g。我需要使用OpenSSL 1.1.0g。请注意,OpenSSL 1.1.0g已安装在我的另一台机器Ubuntu 18中。但是我需要在Ubuntu 16.04中运行python程序,但是我需要特定的OpenSSL 1.1.0g。我做到了:

sudo apt-get upgrade
sudo apt-get update

但是我的Ubuntu计算机中的OpenSSL没有更新。我该如何更新?

我使用python socket, ssl模块在​​端口443中建立TLS连接。如果我将旧的OpenSSL 1.1.0g更新为OpenSSL 1.0.2g,python是否会自动识别OpenSSL 1.1.0g

升级OpenSSL的原因是我需要运行python程序ssl socket,但我需要该程序才能使用OpenSSL 1.1.0g

当我尝试时:

sudo apt-get install openssl

并通过openssl version -a检查OpenSSL版本 我得到的是旧版本OpenSSL 1.0.2g

如何在我的OpenSSL 1.1.0g机器上获取新版本Ubuntu 14.06

2 个答案:

答案 0 :(得分:4)

为什么仅通过更新就无法在Ubuntu 16.04上运行OpenSSL 1.1.0g:

您的Ubuntu 18具有OpenSSL 1.1.0g,因为其存储库中有可用的版本。有时,它在存储库系统上具有一个以上版本的软件包。但是,看来Ubuntu 16.04根本没有您需要的版本。这就是为什么您不是这样的原因,并且仅通过更新就无法使OpenSSL 1.1.0gUbuntu 16.04上工作。存储库中可用的版本为different

以及操作方法:

您将需要手动安装它,或为Ubuntu 16.04找到一个使OpenSSL 1.1.0g在系统上可用的存储库。我不确定是否有可用的存储库,因此,如果要手动安装它,请按以下步骤操作:

wget https://www.openssl.org/source/old/1.1.0/openssl-1.1.0g.tar.gz
tar xzvf openssl-1.1.0g.tar.gz
cd openssl-1.1.0g
./config
make
sudo make install

openssl version -a

就是这样!

警告 。:默认情况下,通过安装系统中不可用的OpenSSL新版本,您引入的版本与系统维护中可用的更新不兼容。 。您需要自己照顾它。也许,根据您的情况,值得使用默认情况下具有您需要的OpenSSL版本的Ubuntu 18。这是最简单,最安全的方法。

希望一切顺利。 祝你好运!

答案 1 :(得分:-1)

这是我从源代码安装最新版本 openssl 的方法。

# Install make and packages required to compile the source code
apt-get install -y libfindbin-libs-perl build-essential

# Download source code
wget https://github.com/openssl/openssl/archive/refs/tags/OpenSSL_1_1_1k.tar.gz -O openssl.tar.gz

# Extract source code
tar -xf openssl.tar.gz

# Go to the source code folder
cd openssl-OpenSSL_1_1_1k

# Configure to compile it
./config --libdir=/usr/local/lib

# Compile with 4 parelel jobs
make -j 4

# Install compiled code
sudo make install

# Move older executable
sudo mv /usr/bin/openssl /usr/bin/openssl-1.0.2g

# Create soft symbolic link to the newer version of openssl
sudo ln -s /usr/local/bin/openssl /usr/bin/openssl

# Make visible the new libraries installed at /usr/local/lib
sudo ldconfig