web-dev-qa-db-ja.com

自作はOpenSSLをリンクすることを拒否

私がしているのは:OSX 10.11.6、自作バージョン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

しかし、私が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

私が依存しているこれらのライブラリをコンパイルしていないので、コンパイラフラグを含めるオプションは私には意味がありません。

EDITdotnetcoreが指示を更新しました:

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/
114
daviddeath

他の答えへのアップデートが示唆するように、古い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

実際には、自作版のSSLを常に使用するようにオペレーティングシステムに指示して、何かが壊れてしまう可能性があるのではなく、dotnetに正しいライブラリを見つける方法を指示しています。

また重要なのは、Microsoftがこの問題を認識しており、a)軽減策とb)長期的な解決策(OpenSSLをdotnetでバンドルする)の両方を持っていることです。

もう1つ注意すべきことは、/usr/local/opt/openssl/libはデフォルトでbrewがリンクされている場所です。

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

何らかの理由でbrewをインストールして別の場所にリンクしている場合は、そのパスがrpathとして使用されるべきパスです。

System.Security.Cryptography.Native.dylibライブラリのrpathを更新したら、対話型セッションを再開する必要があります(つまり、コンソールを閉じて別のセッションを開始する)。

57
Ben Collins

これは私のために働いたものです:

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

このスレッドの@dorlandodeのおかげで https://github.com/Homebrew/brew/pull/597

注意:Opensslを最初から正しくインストールするために時間を費やすことができるようになるまで、一時的な修正としてのみこれを使用しました。覚えていると思いますが、必要な証明書を1つずつ手動でインストールすることが最善の方法であると気付くまでは、1日のうちの大半をデバッグして問題を抱えていました。これを試す前に、@ boukeのコメントにあるリンクを読んでください。

49
rorykoehler

OS X El Capitan 10.11.6では、これらの解決策はどれも私にとってはうまくいきませんでした。おそらくOS Xがopensslのネイティブバージョンを持っているからだと思う。

それで、私は高い道を取って、新しく始めました...


手動インストールとシンボリックリンク

cd /usr/local/src  
  • 「そのようなファイルやディレクトリがありません」というメッセージが表示されたら、次のようにします。

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

Opensslをダウンロードしてください。

curl --remote-name https://www.openssl.org/source/openssl-1.0.2h.tar.gz

展開してcdします。

tar -xzvf openssl-1.0.2h.tar.gz
cd openssl-1.0.2h

コンパイルしてインストールします。

./configure darwin64-x86_64-cc --prefix=/usr/local/openssl-1.0.2h shared
make depend
make
make install

OS Xのopensslを新しく更新されたopensslにシンボリックリンクします。

ln -s /usr/local/openssl-1.0.2h/bin/openssl /usr/local/bin/openssl

端末を閉じて新しいセッションを開き、OS Xが新しいopensslを使用していることを確認します。

openssl version -a
43
mcgwier

brew info opensslを実行して、それが言っている情報を読んでください。

このソフトウェアをPATHの最初に実行する必要がある場合は、次のようにします。echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile

38
Alex Maiburg

あなたのMacを移行することが自作を壊すならば:

私は自分のMacを移行しました、そしてそれはリンクされていませんすべて私の自作インストール - OpenSSLを含みます。これはgem installを壊した、それは私が最初に問題に気付いて、そしてこれを修復しようとし始めた方法です。

何百万もの解決策(OSX Sierraへの移行時 - 10.12.5)が終わると、その解決策は非常にシンプルになりました。

brew reinstall Ruby
brew reinstall openssl
14
tobybot

見つけたものすべてを試しても何もうまくいかなかったので、これを試してみました。

touch ~/.bash_profile; open ~/.bash_profile

ファイル内にこの行が追加されました。

export PATH="$PATH:/usr/local/Cellar/openssl/1.0.2j/bin/openssl"

今では動作します:)

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
9
Jorn

私は同様の事件を抱えています。私はbrew経由でopensslをインストールしてからmitmproxyをインストールするためにpipを使う必要があります。私はbrew link --forceから同じ苦情を受けます。以下は私が到達した解決策です:(ブリューによる強制リンクなしで)

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

これは直接的に質問に対処するものではありません。誰かがpipを使用してopenssl libを必要とする場合に備えて、私はワンライナーを残します。

注:/usr/local/opt/openssl/libパスはbrew info opensslによって取得されます。

8
Pili Hu

これは私のために働いた:

 brew install openssl
 cd /usr/local/include 
 ln -s ../opt/openssl/include/openssl .
6
edwardthesecond

Edwardthesecondからの上記の解決策はSierraでも私のために働きました

 brew install openssl
 cd /usr/local/include 
 ln -s ../opt/openssl/include/openssl 
 ./configure && make

私が前にした他のステップは次のとおりです。

  • brew経由でopensslをインストールする

    brew install openssl
    
  • 自作の提案に従って、opensslをパスに追加する

    brew info openssl
    echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
    
5
Lili

注: https://github.com/Homebrew/brew/pull/612 のため、これは機能しません

今日も同じ問題がありました。私はopenssl 1.0.2をアンインストール(unbrewed ??)し、自作でも1.0.1をインストールしました。その後、Dotnet new/restore/runは正常に動作しました。

Openssl 101をインストールしてください。
brew install homebrew/versions/openssl101
リンク:
ブリューリンク--force homebrew/versions/openssl101

1
user3488820

私にとってこれはうまくいったことです...

./bash_profileを編集して以下のコマンドを追加しました

export PATH = "/ usr/local/opt/openssl/bin:$ PATH"

0
developer