macOS 10.12安装openssl问题

35

尝试使用Homebrew安装openssl:

brew install openssl

在 make 过程中出现以下错误:

clang  -I. -Iinclude -fPIC -arch x86_64 -O3 -Wall -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DRC4_ASM -DMD5_ASM -DAESNI_ASM -DVPAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DX25519_ASM -DPOLY1305_ASM -DOPENSSLDIR="\"/usr/local/etc/openssl@1.1\"" -DENGINESDIR="\"/usr/local/Cellar/openssl@1.1/1.1.1l/lib/engines-1.1\"" -D_REENTRANT -DNDEBUG  -MMD -MF crypto/rand/randfile.d.tmp -MT crypto/rand/randfile.o -c -o crypto/rand/randfile.o crypto/rand/randfile.c
In file included from crypto/rand/rand_unix.c:38:
/usr/include/CommonCrypto/CommonRandom.h:35:9: error: unknown type name 'CCCryptorStatus'
typedef CCCryptorStatus CCRNGStatus;
        ^
crypto/rand/rand_unix.c:385:47: error: use of undeclared identifier 'kCCSuccess'
    if (CCRandomGenerateBytes(buf, buflen) == kCCSuccess)
                                              ^
2 errors generated.
make[1]: *** [crypto/rand/rand_unix.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [all] Error 2

Do not report this issue to Homebrew/brew or Homebrew/core!

Brew 正在尝试安装 openssl 1.1.1l:

==> Downloading https://www.openssl.org/source/openssl-1.1.1l.tar.gz
Already downloaded: /Users/user/Library/Caches/Homebrew/downloads/b6ccc5a2a602c2af3480bbcf1656bd9844595974ba60501871ac12504508e818--openssl-1.1.1l.tar.gz

我需要这个依赖来安装许多其他应用程序/工具,例如wget或python,并且想使用homebrew来完成此操作。

我正在使用的brew版本是:

Homebrew 3.2.9
Homebrew/homebrew-core (git revision fa395c6627; last commit 2021-08-27)
Homebrew/homebrew-cask (git revision 606ed52390; last commit 2021-08-27)

我的 macOS 版本是:10.12.6(Sierra),我使用的是 MacBook Pro(13 英寸,2011 年初版)。

有没有办法避开这个问题来安装 OpenSSL?或者我可以安装 Python 并指定另一个 OpenSSL 作为依赖项吗?

我成功使用以下 Homebrew 命令安装了 OpenSSL 1.0:

brew install rbenv/tap/openssl@1.0

然而,Python 不断尝试使用失败的 openssl 1.1.1l。


我在我的macOS 10.13.6上也遇到了同样的错误。尝试安装gdal依赖项、numpy。还需要openssl@1.1 - user97103
8个回答

49

我通过编辑公式 (brew edit openssl) 并添加内容来解决了它。

-I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
< p > 将参数添加到 configure_args 数组中。

< p > 如下所示:

  def configure_args
    args = %W[
      --prefix=#{prefix}
      --openssldir=#{openssldir}
      no-ssl3
      no-ssl3-method
      no-zlib
      ##### add the line here ####
      -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
    ]
    on_linux do
      args += (ENV.cflags || "").split
      args += (ENV.cppflags || "").split
      args += (ENV.ldflags || "").split
      args << "enable-md2"
    end
    args
  end

3
在我的 macOS 10.13 High Sierra 上对我很有帮助,谢谢! - spyderdyne
请问您要把它添加到哪里? - TGI
2
在10.13 High Sierra上非常好用。感谢@Hulkur。 - Vladimir
这也解决了我的问题。我确实需要使用--export HOMEBREW_EDITOR="/usr/bin/vim"--配置我的brew编辑器,然后将其添加到.zshrc或.bashrc中。之后,'brew edit openssl'就可以工作了。在文件中找到'configure_args',并在闭合括号(即])之前添加上述行。 - Cryptik
2
谢谢,它在我的Mac 10.13.6上也可以工作。 完成需要15分钟。 - user97103
显示剩余3条评论

9

我需要在Sierra(MacOS 10.12)上更改以下文件:

sudo chmod a+w /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/CommonCrypto/CommonRandom.h

vi /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/CommonCrypto/CommonRandom.h

typedef 语句之前,我添加了以下行:

#include "CommonCrypto/CommonCryptoError.h"

同时也按照 @Hulkur 的建议执行以下命令:

brew edit openssl

并增加了

-I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include 

configure_args 中添加到 args 数组中。


这个方法解决了我在MacOS Sierra上的问题。 - Kubuntuer82

3

看起来是openssl本身的一个错误。https://github.com/openssl/openssl/issues/16487


export SDKROOT="/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk "怎么样了?


Homebrew为一些macOS版本提供预构建的软件包。但它不断放弃旧macOS的这种预构建支持。在macOS 10.12上,您需要从源代码构建openssl,并且需要Xcode命令行工具

xcode-select --install

然后再次执行brew install openssl

1
在我的情况下,我已经安装了Xcode 9.4,但在安装openssl时仍然失败了。 - user97103
@user97103,Xcode并不是Xcode命令行工具的超集。您仍然需要安装Xcode CLT才能获取相关库。在这种情况下,需要的是/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/CommonCrypto - Simba
1
我在安装Xcode之前安装了CLT,因为Homebrew需要它。 - user97103
3
很遗憾,安装Xcode命令行工具并不是问题所在 - 它已经安装好了。我还有你上面提到的路径:/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/CommonCrypto - 然而,在进行make/编译时,brew似乎使用了/usr/include/CommonCrypto/CommonRandom.h中的版本 - 有没有办法强制brew使用XCode CLT依赖关系来安装呢? - vinayman

2
我在Mac Sierra 10.13.6 (17G14042)上遇到了同样的问题。 使用命令"brew install openssl@1.1"安装openssl。 我已经更新了openssl。 使用命令"brew edit openssl"编辑openssl。 在def configure_args中添加一行。
-I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
def configure_args 
  args = %W[
    --prefix=#{prefix}
    --openssldir=#{openssldir}
    no-ssl3
    no-ssl3-method
    no-zlib
    -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
  ]

请在此之后运行以下命令:

RUBY_CONFIGURE_OPTS="--disable-install-doc --with-openssl-dir=$(brew --prefix openssl@1.1)" rbenv install 3.0.2

这个对我解决了问题。不确定最后一个命令的作用,但它能正常工作。我使用的是 3.1.0 而不是 3.0.2。谢谢! - Felipe Cerda

1
首先,编辑文件:

$ export EDITOR=nano
$ export VISUAL="$EDITOR"

那么

brew edit openssl

在打开文件之后添加以下行:-I /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
 # help debug inevitable breakage.
  def configure_args
    args = %W[
      --prefix=#{prefix}
      --openssldir=#{openssldir}
      no-ssl3
      no-ssl3-method
      no-zlib
      -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include
    ]
    on_linux do
      args += (ENV.cflags || "").split
      args += (ENV.cppflags || "").split
      args += (ENV.ldflags || "").split
      args << "enable-md2"
    end
    args
  end

保存修改并安装

brew install openssl 

注意:安装时间很长,但已经成功。


在macOS Monterey上无法工作: rvm install "ruby-2.6.5" ... Error running '__rvm_make -j8', please read /Users/xxx/.rvm/log/1647285213_ruby-2.6.5/make.log - belgoros

1

此问题现已解决(自2021年9月11日起),不再需要补丁。


3
不是真的。问题仍然存在。 - Vadim
你为什么这么说?PR已经合并了,我还原了所有更改,现在它可以正常工作。 - Lenny Primak
因为我尝试了在全新安装的操作系统上运行,但仍然遇到了相同的问题。该问题可能没有完全解决,其他答案仍然有用,其中一个确实解决了我的问题。 - Vadim
问题 https://github.com/openssl/openssl/issues/16487 已经解决并集成了相关的补丁。您确定您在这里描述的是该问题吗? - Lenny Primak
我没有看到其他人报告这个问题的新情况。 - Lenny Primak

0
在编辑openssl之后,我遇到了一个新的错误:
=> perl ./Configure --prefix=/usr/local/Cellar/openssl@1.1/1.1.1l --openssldir=/usr/local/etc/openssl@1.1 no-ssl3 no-ssl3-method no-zlib -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include darwin64-x86_64-cc enable-ec_nistp_64_gcc_128
==> make
Last 15 lines from /Users/francis/Library/Logs/Homebrew/openssl@1.1/02.make:
include "CommonCrypto/CommonCryptoError.h"
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/CommonCrypto/CommonRandom.h:35:9: error: expected identifier or '('
include "CommonCrypto/CommonCryptoError.h"
        ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/CommonCrypto/CommonRandom.h:52:1: error: unknown type name 'CCRNGStatus'
CCRNGStatus CCRandomGenerateBytes(void *bytes, size_t count)
^
crypto/rand/rand_unix.c:385:47: error: use of undeclared identifier 'kCCSuccess'
    if (CCRandomGenerateBytes(buf, buflen) == kCCSuccess)
                                              ^
4 errors generated.
make[1]: *** [crypto/rand/rand_unix.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [all] Error 2

编辑

我真傻,我写成了:

include "CommonCrypto/CommonCryptoError.h"

不要使用

#include "CommonCrypto/CommonCryptoError.h"

所以先确保你有一个哈希。


0

对于 MacOS 10.12 之前的版本(例如 10.11 El Capitan),存在另一个问题 - 测试失败:

Test Summary Report
-------------------
../test/recipes/05-test_rand.t (Wstat: 256 Tests: 2 Failed: 1)
  Failed test:  1
  Non-zero exit status: 1
Files=1, Tests=2,  5 wallclock secs ( 0.38 usr  0.06 sys +  5.71 cusr  2.48 csys =  8.63 CPU)
Result: FAIL
make[1]: *** [_tests] Error 1
make: *** [tests] Error 2

关于此问题,OpenSSL已经开放了一个问题和拉取请求来解决: https://github.com/openssl/openssl/issues/16517

https://github.com/openssl/openssl/pull/16587

如果您遇到此问题,请前往投票支持它们。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接