LoginSignup
9
6

旧バージョンのOpenSSLが原因で起こるトラブルの解決策

Last updated at Posted at 2023-09-11

概要

筆者はHomebrewの状態を確認するコマンドbrew doctorコマンドを時々実行して、Your system is ready to brew.のメッセージが出力されるか確認しています。これでエラーや警告が出るのは本来望ましくない状態です。しかし、ある時期のMacではエラーや警告を防ぐのが難しかったこともあり、OSの動作やソースのビルドで問題が発生しない限り、無視していました。しかし、最近はHomebrewが管理しているアプリケーションの格納先が/usr配下から/opt配下に移動したこともあり、そういったトラブルに見舞われることが無くなりました。しかし、今回久方振りに警告が発生し、その対処方法に悩やみつつ、何とか直したので、その方法を備忘録としてまとめておこうと思います。

事の起こり

brew update & brew upgradeを実行しようと思い、その前に念のため、brew doctorを実行しました。その結果が以下です。

$ brew doctor 
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: Some installed formulae are deprecated or disabled.
You should find replacements for the following formulae:
  openssl@1.1

実際のトラブルシューティング

OpenSSLの旧バージョン1.1系は非推奨になりつつありましたが、遂にHomebrewでもdeprecatedになった様です。こういう時は過去の記事に対処方法をまとめておいた記事が有るので参考にします。

実行結果は以下です。何とエラーになりました。。。エラー文をよく読むとPerlとの依存関係が原因の様です。

$ brew uninstall openssl@1.1 
Error: Refusing to uninstall /opt/homebrew/Cellar/openssl@1.1/1.1.1v
because it is required by perl, which is currently installed.
You can override this and force removal with:
  brew uninstall --ignore-dependencies openssl@1.1

Perlはシステム上のツールなどにも使われているスクリプト言語であるため、不用意に依存関係を崩してしまうと最悪システムが動かなくなってしまいます。まずはPerlのバージョン確認です。見たところ、最新版がインストールされていそうです。

$ perl --version

This is perl 5, version 36, subversion 1 (v5.36.1) built for darwin-thread-multi-2level

Copyright 1987-2023, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at https://www.perl.org/, the Perl Home Page.

これはシステムのPerlでは無い可能性が浮上しました。次にtypeコマンドでPerlの実行ファイルのタイプを見てみましょう。

$ type perl
perl はハッシュされています (/opt/homebrew/bin/perl)

これはHomebrewでインストールされているPerlであると分かりました。最悪何とかなる(システムツールとは切り離された)Perlです。ここから思い切って対処しましょう。まずOpenSSL 1.1を強制的にアンインストールします。

$ brew uninstall --ignore-dependencies openssl@1.1 
Uninstalling /opt/homebrew/Cellar/openssl@1.1/1.1.1v... (8,101 files, 18MB)

Warning: The following openssl@1.1 configuration files have not been removed!
If desired, remove them manually with `rm -rf`:
  /opt/homebrew/etc/openssl@1.1
  /opt/homebrew/etc/openssl@1.1/cert.pem
  /opt/homebrew/etc/openssl@1.1/ct_log_list.cnf
  /opt/homebrew/etc/openssl@1.1/ct_log_list.cnf.dist
  /opt/homebrew/etc/openssl@1.1/misc
  /opt/homebrew/etc/openssl@1.1/misc/CA.pl
  /opt/homebrew/etc/openssl@1.1/misc/tsget
  /opt/homebrew/etc/openssl@1.1/misc/tsget.default
  /opt/homebrew/etc/openssl@1.1/misc/tsget.pl
  /opt/homebrew/etc/openssl@1.1/misc/tsget.pl.default
  /opt/homebrew/etc/openssl@1.1/openssl.cnf
  /opt/homebrew/etc/openssl@1.1/openssl.cnf.dist

Warning: The following may be openssl@1.1 configuration files and have not been removed!
If desired, remove them manually with `rm -rf`:
  /opt/homebrew/etc/openssl@3

brew doctorを再実行します。依存関係の警告が出ますが、ここでは一旦無視します。

$ brew doctor 
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: Some installed formulae are missing dependencies.
You should `brew install` the missing dependencies:
  brew install openssl@1.1

Run `brew missing` for more details.

ここで、Perlを再インストールします。

$ brew reinstall perl
~~中略~~
==> Reinstalling perl 
==> Pouring perl--5.36.1.arm64_ventura.bottle.tar.gz
🍺  /opt/homebrew/Cellar/perl/5.36.1: 2,492 files, 67.7MB

改めてbrew doctorを実行します。依存関係のエラー、警告は出ていない様です。しかし、利用している過程でエラーが発生する可能性は有るため、暫く様子を見ることにします。

$ brew doctor 
Your system is ready to brew.

因みに害は無いので旧バージョンのconfigファイルなどは残しておくことにします。必要に応じて.bash_profile内などの環境定数で旧バージョンのOpenSSL関連の物を無効化します。

$ ls /opt/homebrew/etc/openssl@1.1/
cert.pem             ct_log_list.cnf      ct_log_list.cnf.dist misc                 openssl.cnf          openssl.cnf.dist

まとめ

セキュリティ対策のため、古いバージョンのアプリケーション、ライブラリが非推奨になり、非対応になっていくのは致し方ないことなのですが、今回の様に他のアプリケーションに影響が出るのは困ります。今後も似たトラブルにぶつかる時が有ると思いますが、地道にトラブルシューティングした記録を残していこうと思います。

9
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
6