Homebrew拒绝链接OpenSSL

dav*_*ath 122 macos homebrew openssl .net-core

我在:OSX 10.11.6,Homebrew版本0.9.9m OpenSSL 0.9.8zg 2015年7月14日

我正在尝试使用dotnetcore并遵循他们的指示,

我升级/安装了最新版本的openssl:

> brew install openssl
==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2h_1.el_capitan.bottle.tar.gz
Already downloaded: /Users/administrator/Library/Caches/Homebrew/openssl-1.0.2h_1.el_capitan.bottle.tar.gz
==> Pouring openssl-1.0.2h_1.el_capitan.bottle.tar.gz
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /usr/local/etc/openssl/certs

and run
  /usr/local/opt/openssl/bin/c_rehash

This formula is keg-only, which means it was not symlinked into /usr/local.

Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries

Generally there are no consequences of this for you. If you build your
own software and it requires this formula, you'll need to add to your
build variables:

    LDFLAGS:  -L/usr/local/opt/openssl/lib
    CPPFLAGS: -I/usr/local/opt/openssl/include
Run Code Online (Sandbox Code Playgroud)

但是当我尝试链接openssl时,我继续遇到这个链接错误:

> brew link --force openssl
Warning: Refusing to link: openssl
Linking keg-only OpenSSL means you may end up linking against the insecure,
deprecated system version while using the headers from the Homebrew version.
Instead, pass the full include/library paths to your compiler e.g.:
  -I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib
Run Code Online (Sandbox Code Playgroud)

包含编译器标志的选项对我没有意义,因为我没有编译我依赖的这些库.

EDIT dotnetcore已更新说明:

brew update    
brew install openssl    
ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/    
ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/
Run Code Online (Sandbox Code Playgroud)

Ben*_*ins 60

正如对其他答案的更新所示,安装旧的openssl101 brew的解决方法将不再有效.有关现在的解决方法,请参阅dotnet/cli#3964上的此评论.

此处复制的问题中最相关的部分:

我查看了建议在库上设置rpath的另一个选项.我认为以下是一个更好的解决方案,只会影响这个特定的库.

sudo install_name_tool -add_rpath /usr/local/opt/openssl/lib /usr/local/share/dotnet/shared/Microsoft.NETCore.App/1.0.0/System.Security.Cryptography.Native.dylib

和/或如果安装了NETCore 1.0.1,也要为1.0.1执行相同的命令:

sudo install_name_tool -add_rpath /usr/local/opt/openssl/lib /usr/local/share/dotnet/shared/Microsoft.NETCore.App/1.0.1/System.Security.Cryptography.Native.dylib

实际上,我们告诉dotnet如何找到正确的库,而不是告诉操作系统总是使用自制的SSL版本并可能导致某些内容破坏.

同样重要的是,它看起来像微软都意识到这个问题,并和既有)有点无计划减轻以及B)一个长期的解决方案(probaby用的dotnet捆绑的OpenSSL).

另一件需要注意的事情是:/usr/local/opt/openssl/libbrew默认链接的位置:

13:22 $ ls -l /usr/local/opt/openssl
lrwxr-xr-x  1 ben  admin  26 May 15 14:22 /usr/local/opt/openssl -> ../Cellar/openssl/1.0.2h_1
Run Code Online (Sandbox Code Playgroud)

如果无论出于何种原因安装brew并将其链接到不同的位置,那么该路径就是您应该用作rpath的路径.

一旦更新了System.Security.Cryptography.Native.dylib libray的rpath,就需要重新启动交互式会话(即关闭控制台并启动另一个控制台).

  • 随着DOTNET 1.1.0我不得不这样做:`须藤install_name_tool -add_rpath在/ usr /本地的/ opt/OpenSSL的/ lib目录/usr/local/share/dotnet/shared/Microsoft.NETCore.App/1.1.0/System.Security. Cryptography.Native.OpenSsl.dylib` (4认同)
  • 为我工作,在我的情况下,sdk安装到不同的目录,所以我不得不改变路径. (3认同)

ror*_*ler 51

这对我有用:

brew update
brew install openssl
ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/
ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/
ln -s /usr/local/Cellar/openssl/1.0.2j/bin/openssl /usr/local/bin/openssl
Run Code Online (Sandbox Code Playgroud)

感谢@dorlandode在这个帖子上https://github.com/Homebrew/brew/pull/597

注意:我只使用它作为临时修复,直到我可以花时间从头开始正确安装Openssl.我记得在我意识到最好的方法是手动安装我需要的证书之前,我花了一天时间调试并遇到问题.在尝试此操作之前,请阅读@ bouke的评论中的链接.

  • 是最后一个链接`/ usr/local/bin/openssl`的完整路径? (9认同)
  • 这个解决方案对我有用,但由于版本差异,我不得不将`1.0.2j`改为`1.0.2k`.因此用户要注意,您可能需要调整当前版本的路径 (7认同)
  • 酿酒拒绝这样做是有充分理由的.另见:https://github.com/Homebrew/brew/pull/597. (2认同)

小智 45

在OS X El Capitan 10.11.6上,这些解决方案都不适用于我.可能是因为OS X有一个本机版本的openssl,它认为它是优越的,因此,不喜欢篡改.

所以,我走上了高路,开始新鲜......


手动安装和符号链接

cd /usr/local/src  
Run Code Online (Sandbox Code Playgroud)
  • 如果您收到"没有此类文件或目录",请将其设为:

    cd /usr/local && mkdir src && cd src

下载openssl:

curl --remote-name https://www.openssl.org/source/openssl-1.0.2h.tar.gz
Run Code Online (Sandbox Code Playgroud)

提取并cd入:

tar -xzvf openssl-1.0.2h.tar.gz
cd openssl-1.0.2h
Run Code Online (Sandbox Code Playgroud)

编译并安装:

./configure darwin64-x86_64-cc --prefix=/usr/local/openssl-1.0.2h shared
make depend
make
make install
Run Code Online (Sandbox Code Playgroud)

现在符号链接OS X的openssl到你的新的和更新的openssl:

ln -s /usr/local/openssl-1.0.2h/bin/openssl /usr/local/bin/openssl
Run Code Online (Sandbox Code Playgroud)

关闭终端,打开一个新会话,并验证OS X正在使用您的新openssl:

openssl version -a
Run Code Online (Sandbox Code Playgroud)

  • 完成所有这些之后:OpenSSL 0.9.8zh 2016年1月14日建立于:2016年5月15日平台:darwin64-x86_64-llvm (6认同)
  • 以下列方式创建符号链接对我有用:`ln -s /usr/local/openssl-1.0.2h/bin/openssl/usr/local/bin/openssl`.重新启动终端会话后,键入`which openssl`以确保使用更新的1.0.2版本(`/ usr/local/bin/openssl`)而不是内置的(`/ usr/bin/openssl) `). (5认同)
  • 我按照这些说明(非常感谢您的一步一步),它仍然说0.9.8.感谢Olivier提供的替代链接方法. (2认同)

小智 40

只需执行brew info openssl并阅读其中所说的信息:

如果您需要在PATH运行中首先使用此软件: echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile

  • `brew info openssl`为我提供了相同的有用信息.运行上面建议的命令,然后运行`source~/.bash_profile`或打开一个新的终端解决了它. (3认同)
  • 最后.这对我也有用.上面的其他答案没有! (2认同)
  • 或`echo'export PATH ="/ usr/local/opt/openssl/bin:$ PATH"'>>〜/ .zshrc` (2认同)

tob*_*bot 14

如果迁移你的mac破解自制软件:

我迁移了我的mac,它取消所有的自制软件安装 - 包括OpenSSL.这打破了gem install,这是我第一次注意到这个问题并开始尝试修复它.

经过一百万个解决方案(迁移到OSX Sierra - 10.12.5)后,解决方案最终变得非常简单:

brew reinstall ruby
brew reinstall openssl
Run Code Online (Sandbox Code Playgroud)


Jor*_*orn 9

在尝试了我能找到的所有内容并且没有任何效果之后,我就试过了:

touch ~/.bash_profile; open ~/.bash_profile
Run Code Online (Sandbox Code Playgroud)

在文件里面添加了这一行.

export PATH="$PATH:/usr/local/Cellar/openssl/1.0.2j/bin/openssl"
Run Code Online (Sandbox Code Playgroud)

现在它的工作:)

Jorns-iMac:~ jorn$ openssl version -a
OpenSSL 1.0.2j  26 Sep 2016
built on: reproducible build, date unspecified
//blah blah
OPENSSLDIR: "/usr/local/etc/openssl"

Jorns-iMac:~ jorn$ which openssl
/usr/local/opt/openssl/bin/openssl
Run Code Online (Sandbox Code Playgroud)

  • 为了实现这个目的,你需要在末尾添加`/ usr/local/opt/openssl/bin`,*而不用*/openssl`到PATH的*front*,而不是结尾:`PATH =/usr/local/opt/openssl/bin:$ PATH`使用`/ usr/local/opt/openssl`而不是`/ usr/local/Cellar/openssl/$ version`意味着你将自动保持最高 - $ PATH中的最新版本,无需在每次升级时更改它. (2认同)

Pil*_* Hu 8

我有类似的情况.我需要通过brew安装openssl然后使用pip来安装mitmproxy.我得到同样的抱怨brew link --force.以下是我达成的解决方案:(没有通过brew强制链接)

LDFLAGS=-L/usr/local/opt/openssl/lib 
CPPFLAGS=-I/usr/local/opt/openssl/include
PKG_CONFIG_PATH=/usr/local/opt/openssl/lib/pkgconfig 
pip install mitmproxy
Run Code Online (Sandbox Code Playgroud)

这并没有直截了当地解决这个问题.如果有人使用pip并且需要openssl lib,我会离开单行.

注意:/usr/local/opt/openssl/lib路径是通过获得的brew info openssl


小智 7

这对我有用:

 brew install openssl
 cd /usr/local/include 
 ln -s ../opt/openssl/include/openssl .
Run Code Online (Sandbox Code Playgroud)


小智 6

edwardthesecond上面的解决方案也适用于Sierra

 brew install openssl
 cd /usr/local/include 
 ln -s ../opt/openssl/include/openssl 
 ./configure && make
Run Code Online (Sandbox Code Playgroud)

我之前做的其他步骤是: