如何在 Windows 10/11 上从源代码安装 OpenSSL?

pil*_*eup 5 windows openssl

我目前使用的是 Windows 11,但我认为 Windows 10 的步骤相同。

我到处搜索,没有一个教程显示如何在 Windows 上成功安装 OpenSSL。

本网站上的所有答案都只是解决方法,例如使用 Git 版本。我专门使用 XAMPP 中的 OpenSSL,但这不是我想要的。

我希望能够从源代码安装 OpenSSL。另外,当前 Git 和 XAMPP 安装 OpenSSL 版本 1.1.1,我想要 OpenSSL 3。

我已经尝试了所有方法,但 OpenSSL 说明缺少信息。他们只是说一些提示,然后是三个点 (...),例如 ( ./Configure...)。

这就是我试图遵循的地方:

https://github.com/openssl/openssl/blob/master/NOTES-WINDOWS.md#native-builds-using-mingw

对于这个例子,我选择了 MinGW 方法(但是,如果您可以帮助通过其他方法之一成功安装它,那么也没关系,我也会这样做):

我在 Windows 上安装了 MSYS32 和 Perl,但后来我陷入了 MinGW 部分,我已经在 MSYS32 上安装了 MinGW - 我刚刚安装了工具链中的所有软件包:

$ pacman -S mingw-w64-ucrt-x86_64-toolchain
:: There are 19 members in group mingw-w64-ucrt-x86_64-toolchain:
:: Repository ucrt64
   1) mingw-w64-ucrt-x86_64-binutils  2) mingw-w64-ucrt-x86_64-crt-git
   3) mingw-w64-ucrt-x86_64-gcc  4) mingw-w64-ucrt-x86_64-gcc-ada
   5) mingw-w64-ucrt-x86_64-gcc-fortran  6) mingw-w64-ucrt-x86_64-gcc-libgfortran
   7) mingw-w64-ucrt-x86_64-gcc-libs  8) mingw-w64-ucrt-x86_64-gcc-objc
   9) mingw-w64-ucrt-x86_64-gdb  10) mingw-w64-ucrt-x86_64-gdb-multiarch
   11) mingw-w64-ucrt-x86_64-headers-git  12) mingw-w64-ucrt-x86_64-libgccjit
   13) mingw-w64-ucrt-x86_64-libmangle-git  14) mingw-w64-ucrt-x86_64-libwinpthread-git
   15) mingw-w64-ucrt-x86_64-make  16) mingw-w64-ucrt-x86_64-pkgconf
   17) mingw-w64-ucrt-x86_64-tools-git  18) mingw-w64-ucrt-x86_64-winpthreads-git
   19) mingw-w64-ucrt-x86_64-winstorecompat-git
Run Code Online (Sandbox Code Playgroud)

但是,gcc命令仍然不起作用。我相信这与我没有将其添加到 MSYS32 中有关PATH,但没有说明如何执行此操作(而且,即使在安装整个工具链之后,它C:\msys64\mingw64\bin也是空的!)

而且,他们后来说:

除此之外,请遵循 INSTALL.md 中的 Unix / Linux 说明。

太棒了,所以我去了INSTALL.md,那里的所有内容只是另一个提示:

$ ./Configure
$ make
$ make test
Run Code Online (Sandbox Code Playgroud)

为什么在 Windows 上构建和安装 OpenSSL 如此复杂?我想要来自源代码的官方信息,而不是像通过 Git 或 XAMPP 或未知的第三方那样的解决方法。(他们为什么不提供一个.exe呢?)

希望这篇文章能够作为任何想要在 Windows 上安装 OpenSSL 的人未来的参考,并提供完整的说明

谢谢

Ihd*_*ina 7

打开Command PromptAdministratorthen 拼写错误winget install opensslthen enter


pil*_*eup 6

我终于成功了,我安装OpenSSL 3.2.0-dev在Windows 11上。

这些是详细步骤,以便将来任何人都可以做到:

我最终使用了第一种方法,即 C++,如下所示: https: //github.com/openssl/openssl/blob/master/NOTES-WINDOWS.md#quick-start

以下是说明,我尽力使其尽可能详细,如果需要更改或修复,请告诉我:

第一步:安装必要的软件

第 1 步:安装 Perl - 安装该Strawberry版本,安装更容易,它会安装所有内容,还会自动将它们添加到 WindowsPATH变量中

步骤 2:安装 NASM,并将其添加到 Windows 系统(或您的用户的)PATH变量中。我最终仅将其添加到我的用户变量 PATH 中:C:\Users\<username>\AppData\Local\bin\NASM

步骤3:安装Visual Studio(我有Visual Studio Community 2022),并安装Desktop development with c++. 我最终选择了以下软件包(我确信并非所有软件包都是必需的,但如果您知道,请告诉我我需要哪些软件包,以便我更新照片以避免安装太多软件包): 在此输入图像描述

步骤 4:下载并安装 Visual Studio 的构建工具(我假设将来此链接会更改,因此请查找适合您的 Visual Studio 版本的构建工具安装链接): https: //visualstudio.microsoft.com/downloads/# Visual Studio 2022 构建工具

步骤 5:安装构建工具后,启动 Visual Studio 安装程序。在安装程序中,您现在将看到构建工具。单击 Visual Studio 构建工具下的“修改”:

在此输入图像描述

然后安装 OpenSSL 安装所需的软件包,这就是要安装的内容nmake

在此输入图像描述

然后,构建和安装步骤:

第 6 步:将 openssl 存储库克隆到 PC 上的某个文件夹(我克隆了它,C:/所以最终得到了C:/openssl/),并通过运行以下命令来修复行结尾:

> git clone git://git.openssl.org/openssl.git

> cd openssl
> git config core.autocrlf false
> git config core.eol lf
> git checkout .
Run Code Online (Sandbox Code Playgroud)

更新:如果您想要另一个版本,请克隆存储库而不签出,修复行结尾,然后签出到您想要的版本。例如,如果您想要3.1.0稳定(请注意 no-checkout 的 -n 标志):

> git clone -n git://git.openssl.org/openssl.git

> cd openssl
> git config core.autocrlf false
> git config core.eol lf
> git checkout openssl-3.1.0
Run Code Online (Sandbox Code Playgroud)

步骤 7:在 Windows 搜索中,搜索“Developer Command Prompt for VS 2022”(或您的任何版本),然后以管理员身份运行:

在此输入图像描述

这将打开这个命令窗口:

在此输入图像描述

第8步:您需要为要安装的OpenSSL版本设置正确的环境,否则构建将失败。就我而言,我想为 64 位系统安装 OpenSSL,复制粘贴以下内容(包括引号,并根据您的 Visual Studio 安装路径更改路径)

"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat"

然后将设置环境,如下所示:

在此输入图像描述

步骤 9:从同一个开发人员命令提示符中,cd进入您克隆 openssl 源代码的文件夹(在我的例子中是 )C:/openssl,然后按照 OpenSSL 指南中的步骤进行操作:

> perl Configure VC-WIN64A
> nmake
> nmake test
> nmake install
Run Code Online (Sandbox Code Playgroud)

请注意,这些步骤需要时间,我大约花了 20-30 分钟才能完成所有这 4 个命令

第10步:就是这样!已安装!您可以在以下位置找到 OpenSSL 可执行文件 (openssl.exe) C:\openssl\appsPATH(如果需要的话,可以将其添加到 Windows 系统或用户变量中)

就我而言,当我跑步时openssl version我看到OpenSSL 3.2.0-dev (Library: OpenSSL 3.2.0-dev )

  • 嗯,这非常复杂。 (5认同)