OpenSSL是安全套接字层(SSL)和传输层安全性(TLS)协议的广泛使用的开源实现,用于保护网络上的通信。它提供了一个加密函数库和命令行工具来使用它们,包括对称密码、公钥密码和哈希函数,以及用于管理数字证书和证书签名请求的函数。OpenSSL也被用作许多其他软件库和工具的基础,但是,保持OpenSSL版本最新以避免已知漏洞非常重要。
在 Ubuntu 22.04 LTS Jammy Jellyfish 上安装 OpenSSL
第 1 步。第一步是将系统更新到最新版本的软件包列表。为此,请运行以下命令:
<span class="pln">sudo apt update sudo apt install build</span><span class="pun">-</span><span class="pln">essential checkinstall zlib1g</span><span class="pun">-</span><span class="pln">dev</span>
第 2 步。在 Ubuntu 22.04 LTS 上安装 OpenSSL。
默认情况下,OpenSSL 在 Ubuntu 基础存储库中不可用。现在运行以下命令,将OpenSSL的最新源代码下载到您的Ubuntu系统:
<span class="pln">cd </span><span class="pun">/</span><span class="pln">usr</span><span class="pun">/</span><span class="kwd">local</span><span class="pun">/</span><span class="pln">src</span><span class="pun">/</span><span class="pln"> wget https</span><span class="pun">:</span><span class="com">//www.openssl.org/source/openssl-3.0.7.tar.gz</span>
下载完成后,继续将存档内容解压缩到您的系统:
<span class="pln">tar </span><span class="pun">-</span><span class="pln">xf openssl</span><span class="pun">-</span><span class="lit">3.0</span><span class="pun">.</span><span class="lit">7.tar</span><span class="pun">.</span><span class="pln">gz cd openssl</span><span class="pun">-</span><span class="lit">3.0</span><span class="pun">.</span><span class="lit">7</span>
在继续安装之前,请切换到您提取的 OpenSSL 目录。要验证您是否位于正确的位置,请通过键入“”列出其内容:ls
<span class="pln">ls ACKNOWLEDGEMENTS</span><span class="pun">.</span><span class="pln">md HACKING</span><span class="pun">.</span><span class="pln">md NOTES</span><span class="pun">-</span><span class="pln">PERL</span><span class="pun">.</span><span class="pln">md README</span><span class="pun">-</span><span class="pln">PROVIDERS</span><span class="pun">.</span><span class="pln">md build</span><span class="pun">.</span><span class="pln">info e_os</span><span class="pun">.</span><span class="pln">h providers AUTHORS</span><span class="pun">.</span><span class="pln">md INSTALL</span><span class="pun">.</span><span class="pln">md NOTES</span><span class="pun">-</span><span class="pln">UNIX</span><span class="pun">.</span><span class="pln">md README</span><span class="pun">.</span><span class="pln">md config engines ssl CHANGES</span><span class="pun">.</span><span class="pln">md LICENSE</span><span class="pun">.</span><span class="pln">txt NOTES</span><span class="pun">-</span><span class="pln">VALGRIND</span><span class="pun">.</span><span class="pln">md SUPPORT</span><span class="pun">.</span><span class="pln">md config</span><span class="pun">.</span><span class="pln">com external test CONTRIBUTING</span><span class="pun">.</span><span class="pln">md NEWS</span><span class="pun">.</span><span class="pln">md NOTES</span><span class="pun">-</span><span class="pln">VMS</span><span class="pun">.</span><span class="pln">md VERSION</span><span class="pun">.</span><span class="pln">dat configdata</span><span class="pun">.</span><span class="pln">pm</span><span class="pun">.</span><span class="kwd">in</span><span class="pln"> fuzz tools </span><span class="typ">Configurations</span><span class="pln"> NOTES</span><span class="pun">-</span><span class="pln">ANDROID</span><span class="pun">.</span><span class="pln">md NOTES</span><span class="pun">-</span><span class="pln">WINDOWS</span><span class="pun">.</span><span class="pln">md VMS crypto include util </span><span class="typ">Configure</span><span class="pln"> NOTES</span><span class="pun">-</span><span class="pln">DJGPP</span><span class="pun">.</span><span class="pln">md README</span><span class="pun">-</span><span class="pln">ENGINES</span><span class="pun">.</span><span class="pln">md apps demos ms wycheproof FAQ</span><span class="pun">.</span><span class="pln">md NOTES</span><span class="pun">-</span><span class="pln">NONSTOP</span><span class="pun">.</span><span class="pln">md README</span><span class="pun">-</span><span class="pln">FIPS</span><span class="pun">.</span><span class="pln">md appveyor</span><span class="pun">.</span><span class="pln">yml doc os</span><span class="pun">-</span><span class="pln">dep</span>
让我们使用以下命令检查已安装的版本:
<span class="pln">openssl version </span><span class="pun">-</span><span class="pln">a</span>
接下来,我们从源代码编译,并运行以下命令:
<span class="pln">cd </span><span class="pun">/</span><span class="pln">usr</span><span class="pun">/</span><span class="kwd">local</span><span class="pun">/</span><span class="pln">src</span><span class="pun">/</span><span class="pln">openssl</span><span class="pun">-</span><span class="lit">3.0</span><span class="pun">.</span><span class="lit">7</span> <span class="pun">./</span><span class="pln">config </span><span class="pun">--</span><span class="pln">prefix</span><span class="pun">=</span><span class="str">/usr/</span><span class="kwd">local</span><span class="pun">/</span><span class="pln">ssl </span><span class="pun">--</span><span class="pln">openssldir</span><span class="pun">=</span><span class="str">/usr/</span><span class="kwd">local</span><span class="pun">/</span><span class="pln">ssl shared zlib make make test</span>
输出:
<span class="typ">Configuring</span> <span class="typ">OpenSSL</span><span class="pln"> version </span><span class="lit">3.0</span><span class="pun">.</span><span class="lit">7</span> <span class="kwd">for</span><span class="pln"> target linux</span><span class="pun">-</span><span class="pln">x86_64 </span><span class="typ">Using</span><span class="pln"> os</span><span class="pun">-</span><span class="pln">specific seed configuration </span><span class="typ">Creating</span><span class="pln"> configdata</span><span class="pun">.</span><span class="pln">pm </span><span class="typ">Running</span><span class="pln"> configdata</span><span class="pun">.</span><span class="pln">pm </span><span class="typ">Creating</span> <span class="typ">Makefile</span><span class="pun">.</span><span class="kwd">in</span> <span class="typ">Creating</span> <span class="typ">Makefile</span> <span class="pun">**********************************************************************</span> <span class="pun">***</span> <span class="pun">***</span> <span class="pun">***</span> <span class="typ">OpenSSL</span><span class="pln"> has been successfully configured </span><span class="pun">***</span> <span class="pun">***</span> <span class="pun">***</span> <span class="pun">***</span> <span class="typ">If</span><span class="pln"> you encounter a problem </span><span class="kwd">while</span><span class="pln"> building</span><span class="pun">,</span><span class="pln"> please open an </span><span class="pun">***</span> <span class="pun">***</span><span class="pln"> issue on </span><span class="typ">GitHub</span> <span class="pun"><</span><span class="pln">https</span><span class="pun">:</span><span class="com">//github.com/openssl/openssl/issues> ***</span> <span class="pun">***</span> <span class="kwd">and</span><span class="pln"> include the output </span><span class="kwd">from</span><span class="pln"> the following command</span><span class="pun">:</span> <span class="pun">***</span> <span class="pun">***</span> <span class="pun">***</span> <span class="pun">***</span><span class="pln"> perl configdata</span><span class="pun">.</span><span class="pln">pm </span><span class="pun">--</span><span class="kwd">dump</span> <span class="pun">***</span> <span class="pun">***</span> <span class="pun">***</span> <span class="pun">***</span> <span class="pun">(</span><span class="typ">If</span><span class="pln"> you are </span><span class="kwd">new</span><span class="pln"> to </span><span class="typ">OpenSSL</span><span class="pun">,</span><span class="pln"> you might want to consult the </span><span class="pun">***</span> <span class="pun">***</span> <span class="str">'Troubleshooting'</span><span class="pln"> section </span><span class="kwd">in</span><span class="pln"> the INSTALL</span><span class="pun">.</span><span class="pln">md file first</span><span class="pun">)</span> <span class="pun">***</span> <span class="pun">***</span> <span class="pun">***</span> <span class="pun">**********************************************************************</span>
请等待编译器完成,然后再继续执行命令:make install
<span class="pln">make install</span>
成功安装 OpenSSL 后,继续配置库路径:
<span class="pln">cd </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">ld</span><span class="pun">.</span><span class="pln">so</span><span class="pun">.</span><span class="pln">conf</span><span class="pun">.</span><span class="pln">d</span><span class="pun">/</span><span class="pln"> nano openssl</span><span class="pun">-</span><span class="lit">3.0</span><span class="pun">.</span><span class="lit">7.conf</span>
粘贴 OpenSSL 库路径目录:
<span class="str">/usr/</span><span class="kwd">local</span><span class="pun">/</span><span class="pln">ssl</span><span class="pun">/</span><span class="pln">lib64</span>
保存并关闭文件,然后使用以下命令重新加载动态链接:
<span class="pln">sudo ldconfig </span><span class="pun">-</span><span class="pln">v</span>
第 3 步。配置 OpenSSL 二进制文件。
我们需要将 中的 OpenSSL 二进制文件替换为 中的新版本。首先备份现有文件:/usr/bin/openssl
/bin/openssl
/usr/local/ssl/bin/openssl
<span class="pln">mv </span><span class="pun">/</span><span class="pln">usr</span><span class="pun">/</span><span class="pln">bin</span><span class="pun">/</span><span class="pln">c_rehash </span><span class="pun">/</span><span class="pln">usr</span><span class="pun">/</span><span class="pln">bin</span><span class="pun">/</span><span class="pln">c_rehash</span><span class="pun">.</span><span class="pln">bak mv </span><span class="pun">/</span><span class="pln">usr</span><span class="pun">/</span><span class="pln">bin</span><span class="pun">/</span><span class="pln">openssl </span><span class="pun">/</span><span class="pln">usr</span><span class="pun">/</span><span class="pln">bin</span><span class="pun">/</span><span class="pln">openssl</span><span class="pun">.</span><span class="pln">bak</span>
接下来,使用收藏的文本编辑器编辑“”文件:/etc/environment
<span class="pln">nano </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">environment</span>
添加新的 OpenSSL 二进制目录:
<span class="pln">PATH</span><span class="pun">=</span><span class="str">"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/ssl/bin"</span>
保存并关闭文件,然后需要重新加载环境变量:
<span class="pln">source </span><span class="pun">/</span><span class="pln">etc</span><span class="pun">/</span><span class="pln">environment echo $PATH</span>
现在我们使用以下命令再次检查 OpenSSL 二进制文件:
<span class="pln">which openssl</span>
感谢您使用本教程在 Ubuntu 22.04 LTS Jammy Jellyfish 系统上安装最新的 OpenSSL。有关其他帮助或有用信息,我们建议您查看 OpenSSL 网站。