macOS 上的 OpenSSL 1.0.2m

OpenSSL 1.0.2m on macOS

为了构建一个特定的库,我需要带有 devel 包的 openssl 库版本 1.0.2m。我在 macOS 上工作。使用 brew install openssl 安装最新版本 1.1.1d。

由于 OpenSSL 1.0.2 将于 2019 年底停产,因此无法再通过 Homebrew 获得。 Homebrew 2.2.0 announcement.

中提到了这一点

自己从源代码构建和安装 OpenSSL 1.0.2 相当简单。您可以从 Old 1.0.2 Releases page and follow the instructions found in INSTALL.

下载您需要的版本

也可以恢复旧的公式并从中安装,但我不能保证效果如何。以下步骤确实完成了安装过程:

$ git clone https://github.com/Homebrew/homebrew-core.git
$ cd homebrew-core
$ git checkout 75b57384 Formula/openssl.rb
$ brew install Formula/openssl.rb

对我来说,这表明:

Warning: openssl 1.1.1d is available and more recent than version 1.0.2m.
==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2m.high_sierra.bottle.tar.gz

然后愉快地继续下去。最后的快速尝试让我们相信它的效果很好:

$ /usr/local/opt/openssl/bin/openssl version
OpenSSL 1.0.2m  2 Nov 2017

如果你不想直接使用git,你也可以尝试下载那个版本的openssl.rb from gitHub.com和运行brew install


如果你想知道那个提交哈希是从哪里来的,我碰巧知道这个公式曾经被称为 -- surprise -- openssl.rb(但是使用 git 来查询删除的文件会也有效)。因此,我检查了 Formula/openssl.rb 的历史记录并发现:

$ git log -- Formula/openssl.rb
...
commit 75b573845a17aaf3f7c84dc58e97cf5fe39a502b
Author: BrewTestBot <brew-test-bot@googlegroups.com>
Date:   Thu Nov 2 17:20:33 2017 +0000

    openssl: update 1.0.2m bottle.

无需下载特定版本的 Formula/openssl.rb,您可以只使用对具有特定提交 SHA 的文件的原始引用,如前所述 here

因此,对于版本 1.0.2t 的最新更新,SHA 是 8b9d6d688f483a0f33fcfc93d433de501b9c3513

commit 8b9d6d688f483a0f33fcfc93d433de501b9c3513
Author: BrewTestBot <homebrew-test-bot@lists.sfconservancy.org>
Date:   Sat Sep 28 19:38:49 2019 +0000

    openssl: update 1.0.2t bottle.

所以我会执行下面的命令来安装1.0.2t。

brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/8b9d6d688f483a0f33fcfc93d433de501b9c3513/Formula/openssl.rb

最近,由于 openssl 版本从 1.0 更新到 1.1,我很苦恼,想将其恢复到旧版本。除了下面给出的解决方案外,没有其他解决方案对我有用:

brew install rbenv/tap/openssl@1.0 rvm reinstall 1.9.3-p551 --with-openssl-dir='/usr/local/opt/openssl@1.0' gem update --system

1- 下载文件:

wget https://github.com/tebelorg/Tump/releases/download/v1.0.0/openssl.rb

2 - 运行 brew 下载文件:

brew install openssl.rb

其他解决方案将不起作用,因为您会收到此错误"Calling Installation of openssl from a GitHub commit URL is disabled! Use 'brew extract openssl' to stable tap on GitHub instead."以下步骤将修复它:

  1. 首先去本地安装homebrew
cd /usr/local/Homebrew/
  1. Homebrew 2.5 删除了直接从 git 存储库安装公式的选项,因此我们需要检查旧版本
git checkout 2.3.0
  1. 安装openssl latest 1.0.x版本
HOMEBREW_NO_AUTO_UPDATE=1 brew install https://github.com/tebelorg/Tump/releases/download/v1.0.0/openssl.rb
  1. 返回当前版本的自制软件
git co -
  1. 告诉 brew 使用旧版本 openssl 这样你可以选择使用哪个版本,如果你已经安装了
brew switch openssl 1.0.2t

也许这不是一个完美的主意,但它解决了我的问题(找不到 libssl.1.0.0.dylib 图片):

sudo ln -s /usr/lib/libssl.dylib /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
sudo ln -s /usr/lib/libcrypto.dylib /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib

希望对你有用!

this reply

这是 openssl@1.0.2

的 linux-brew 公式
brew install https://raw.githubusercontent.com/Homebrew/linuxbrew-core/20ab55b304597c6c47149dc0e50bd5f7ea45b678/Formula/openssl.rb

更新 - 我认为我一直在反对,因为我只是发布了一个没有解决方案的 link。所以这是解决方案:

  • 下载 this OpenSSL V1.0 的公式(已打补丁以与 arm64 处理器一起使用)
  • 安装它brew install openssl@1.0.rb
  • 将此版本添加到 PATH 的开头。 注意:确保 RVM 是 shell 配置文件 (.zshrc / .bashrc)
    中的最后一个 PATH 变量更改 echo 'export PATH="/opt/homebrew/opt/openssl@1.0/bin:$PATH"' >> ~/.zshrc
  • 导出一些需要的环境变量
 export LDFLAGS="-L/opt/homebrew/opt/openssl@1.0/lib"
 export CPPFLAGS="-I/opt/homebrew/opt/openssl@1.0/include"
 export PKG_CONFIG_PATH="/opt/homebrew/opt/openssl@1.0/lib/pkgconfig"
  • 重新加载您的 shell 配置 source ~/.zshrc
  • 验证您的 openssl 版本
> openssl version
OpenSSL 1.0.2u  20 Dec 2019
  • 禁用 RVM autolibs rvm autolibs disable
  • 导出一些环境变量以避免编译错误
export RUBY_CFLAGS=-DUSE_FFI_CLOSURE_ALLOC
export optflags="-Wno-error=implicit-function-declaration"
  • 安装Ruby
rvm install 2.3.0 --with-openssl-dir=/opt/homebrew/opt/openssl@1.0

Ref