簡體   English   中英

手動更新 windows x64 上 python 使用的 openssl 版本

[英]Manually update the openssl version used by python on windows x64

我正在為 windows 10 (x64) 運行 python 3.9.1。 I have noticed the openssl dll files shipped with python (libcrypto-1_1.dll & libssl-1_1.dll) are only version 1.1.1.7. 因此,我想用最新版本替換這些。

按照發布中的說明,我已經能夠在 windows 10 中成功構建 openssl 1.1.1.9。 我正在使用 Microsoft Visual Studio 2019 + 草莓 perl + nasm。 我使用 vs 2019 的 x64 本機工具命令提示符運行以下配置命令:

perl Configure VC-WIN64A

然后我運行 nmake 命令。 這會產生我需要的兩個 dll:libcrypto-1_1-x64.dll 和 libssl-1_1-x64.dll

我重命名了這兩個文件以刪除名稱末尾的“-x64”,然后用它們替換 python 安裝中的現有 dll。

當我嘗試在 python 中導入 ssl 庫時,出現錯誤:

ImportError: DLL load failed while importing _ssl: The specified module could not be found.

然后,我使用 vs 2019 的 x86 本機工具命令提示符和命令為 x86 構建 openssl 和命令:

perl Configure VC-WIN32

然后我運行了 nmake,它產生了: libcrypto-1_1.dll 和 libssl-1_1.dll

我用這些替換了 python 安裝中的 dll。 當我嘗試在 python 中導入 ssl 庫時,我得到:

ImportError: DLL load failed while importing _ssl: %1 is not a valid Win32 application.

我有理由確定我需要 x64 版本的 dll,因為 (1) 我的 python 安裝是 x64 (2) 當我在 python 上使用 Visual Studio dumpbin.exe 工具時,我使用了 dll 來檢查他們在其中說“x64”的標題(3) x64 dll 的大小與 python 隨附的大小相似,而 x86 版本更小。

對於舊版本的 python,我曾經能夠按照上述步驟執行此操作。 該版本隨附 openssl 1.1.3(可能是 4),我為 1.1.6(可能是 7)構建了 dll 並替換了它們,python 沒有問題。 默認配置腳本是否可能在這些版本上發生了更改,以至於默認 windows x64 配置不再以與 python 一起使用的方式構建 openssl,因此我需要使用自定義設置?

我認為本頁第 1.3 節中的信息可能是相關的,但如果是,我不確定如何在 openssl 構建過程中實現該信息。

我設法在一些幫助下解決了這個問題。

CPython 用於為 windows 安裝程序構建 OpenSSL 的腳本實際上運行以下命令:

Perl Configure VC-WIN64A-masm no-asm

代替

Perl Configure VC-WIN64A

在我原來的帖子中描述的設置上運行正確的命令后,我能夠換出 dll 並且 python 毫無問題地接受了它們。

ssl.OPENSSL_VERSION 現在輸出“OpenSSL 1.1.1i 2020 年 12 月 8 日”。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM