Homebrew 및 openssl 설치

Homebrew 및 openssl 설치

2022-10-04 last update

13 minutes reading openssl homebrew 설치 Mac

ESP32 개발 환경 ESP-IDF 도입 중



분명히 openssl 버전이 오래된 것처럼 설치가 error로 종료되었습니다.
openssl을 새롭게해야하는 것 같습니다.
MacBook-Pro:tools mgr206$ sudo easy_install pip
Password:
Searching for pip
Reading https://pypi.python.org/simple/pip/
Download error on https://pypi.python.org/simple/pip/: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590) -- Some packages may not be found!
Couldn't find index page for 'pip' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.python.org/simple/
Download error on https://pypi.python.org/simple/: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590) -- Some packages may not be found!
No local packages or download links found for pip
error: Could not find suitable distribution for Requirement.parse('pip')

MacBook Pro는 개발용으로 별로, 라고 할까 전혀 사용하고 있지 않기 때문에 각종 패키지가 낡습니다.
openssl의 버전을 확인하고 보면. . . 2년 이상 전의 릴리스군요. 업데이트하겠습니다.
MacBook-Pro:tools mgr206$ openssl version
OpenSSL 0.9.8zh 14 Jan 2016

Homebrew 공식 페이지



홈브류 공식 페이지로 이동하여 다음 명령을 복사합니다. 공식 페이지에서도 「이 스크립트를 터미널에 붙여 실행해 주세요.」라고 정중하게도 기재해 줍니다.
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

설치 수행



실행하면 다운로드 및 설치가 시작됩니다. 중간에 Enter 키를 누르라는 메시지가 표시되므로 누르십시오.
MacBook-Pro:tools mgr206$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
==> This script will install:
/usr/local/bin/brew
/usr/local/share/doc/homebrew
/usr/local/share/man/man1/brew.1
/usr/local/share/zsh/site-functions/_brew
/usr/local/etc/bash_completion.d/brew
/usr/local/Homebrew
==> The following existing directories will be made group writable:
/usr/local/bin
==> The following existing directories will have their owner set to mgr206:
/usr/local/bin
==> The following existing directories will have their group set to admin:
/usr/local/bin
==> The following new directories will be created:
/usr/local/Cellar
/usr/local/Homebrew
/usr/local/Frameworks
/usr/local/etc
/usr/local/include
/usr/local/lib
/usr/local/opt
/usr/local/sbin
/usr/local/share
/usr/local/share/zsh
/usr/local/share/zsh/site-functions
/usr/local/var

Press RETURN to continue or any other key to abort
==> /usr/bin/sudo /bin/chmod u+rwx /usr/local/bin
==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/bin
==> /usr/bin/sudo /usr/sbin/chown mgr206 /usr/local/bin
==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/bin
==> /usr/bin/sudo /bin/mkdir -p /usr/local/Cellar /usr/local/Homebrew /usr/local/Frameworks /usr/local/etc /usr/local/include /usr/local/lib /usr/local/opt /usr/local/sbin /usr/local/share /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var
==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/Cellar /usr/local/Homebrew /usr/local/Frameworks /usr/local/etc /usr/local/include /usr/local/lib /usr/local/opt /usr/local/sbin /usr/local/share /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var
==> /usr/bin/sudo /bin/chmod 755 /usr/local/share/zsh /usr/local/share/zsh/site-functions
==> /usr/bin/sudo /usr/sbin/chown mgr206 /usr/local/Cellar /usr/local/Homebrew /usr/local/Frameworks /usr/local/etc /usr/local/include /usr/local/lib /usr/local/opt /usr/local/sbin /usr/local/share /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var
==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/Cellar /usr/local/Homebrew /usr/local/Frameworks /usr/local/etc /usr/local/include /usr/local/lib /usr/local/opt /usr/local/sbin /usr/local/share /usr/local/share/zsh /usr/local/share/zsh/site-functions /usr/local/var
==> /usr/bin/sudo /bin/mkdir -p /Users/mgr206/Library/Caches/Homebrew
==> /usr/bin/sudo /bin/chmod g+rwx /Users/mgr206/Library/Caches/Homebrew
==> /usr/bin/sudo /usr/sbin/chown mgr206 /Users/mgr206/Library/Caches/Homebrew
==> /usr/bin/sudo /bin/mkdir -p /Library/Caches/Homebrew
==> /usr/bin/sudo /bin/chmod g+rwx /Library/Caches/Homebrew
==> /usr/bin/sudo /usr/sbin/chown mgr206 /Library/Caches/Homebrew
==> Downloading and installing Homebrew...
remote: Counting objects: 100655, done.
remote: Total 100655 (delta 0), reused 0 (delta 0), pack-reused 100655
Receiving objects: 100% (100655/100655), 22.95 MiB | 2.75 MiB/s, done.
Resolving deltas: 100% (73308/73308), done.
From https://github.com/Homebrew/brew
 * [new branch]          master     -> origin/master
 * [new tag]             0.1        -> 0.1
 * [new tag]             0.2        -> 0.2
 * [new tag]             0.3        -> 0.3
 * [new tag]             0.4        -> 0.4
 * [new tag]             0.5        -> 0.5
 * [new tag]             0.6        -> 0.6
 * [new tag]             0.7        -> 0.7
 * [new tag]             0.7.1      -> 0.7.1
 * [new tag]             0.8        -> 0.8
 * [new tag]             0.8.1      -> 0.8.1
 * [new tag]             0.9        -> 0.9
 * [new tag]             0.9.1      -> 0.9.1
 * [new tag]             0.9.2      -> 0.9.2
 * [new tag]             0.9.3      -> 0.9.3
 * [new tag]             0.9.4      -> 0.9.4
 * [new tag]             0.9.5      -> 0.9.5
 * [new tag]             0.9.8      -> 0.9.8
 * [new tag]             0.9.9      -> 0.9.9
 * [new tag]             1.0.0      -> 1.0.0
 * [new tag]             1.0.1      -> 1.0.1
 * [new tag]             1.0.2      -> 1.0.2
 * [new tag]             1.0.3      -> 1.0.3
 * [new tag]             1.0.4      -> 1.0.4
 * [new tag]             1.0.5      -> 1.0.5
 * [new tag]             1.0.6      -> 1.0.6
 * [new tag]             1.0.7      -> 1.0.7
 * [new tag]             1.0.8      -> 1.0.8
 * [new tag]             1.0.9      -> 1.0.9
 * [new tag]             1.1.0      -> 1.1.0
 * [new tag]             1.1.1      -> 1.1.1
 * [new tag]             1.1.10     -> 1.1.10
 * [new tag]             1.1.11     -> 1.1.11
 * [new tag]             1.1.12     -> 1.1.12
 * [new tag]             1.1.13     -> 1.1.13
 * [new tag]             1.1.2      -> 1.1.2
 * [new tag]             1.1.3      -> 1.1.3
 * [new tag]             1.1.4      -> 1.1.4
 * [new tag]             1.1.5      -> 1.1.5
 * [new tag]             1.1.6      -> 1.1.6
 * [new tag]             1.1.7      -> 1.1.7
 * [new tag]             1.1.8      -> 1.1.8
 * [new tag]             1.1.9      -> 1.1.9
 * [new tag]             1.2.0      -> 1.2.0
 * [new tag]             1.2.1      -> 1.2.1
 * [new tag]             1.2.2      -> 1.2.2
 * [new tag]             1.2.3      -> 1.2.3
 * [new tag]             1.2.4      -> 1.2.4
 * [new tag]             1.2.5      -> 1.2.5
 * [new tag]             1.2.6      -> 1.2.6
 * [new tag]             1.3.0      -> 1.3.0
 * [new tag]             1.3.1      -> 1.3.1
 * [new tag]             1.3.2      -> 1.3.2
 * [new tag]             1.3.3      -> 1.3.3
 * [new tag]             1.3.4      -> 1.3.4
 * [new tag]             1.3.5      -> 1.3.5
 * [new tag]             1.3.6      -> 1.3.6
 * [new tag]             1.3.7      -> 1.3.7
 * [new tag]             1.3.8      -> 1.3.8
 * [new tag]             1.3.9      -> 1.3.9
 * [new tag]             1.4.0      -> 1.4.0
 * [new tag]             1.4.1      -> 1.4.1
 * [new tag]             1.4.2      -> 1.4.2
 * [new tag]             1.4.3      -> 1.4.3
 * [new tag]             1.5.0      -> 1.5.0
 * [new tag]             1.5.1      -> 1.5.1
 * [new tag]             1.5.10     -> 1.5.10
 * [new tag]             1.5.11     -> 1.5.11
 * [new tag]             1.5.12     -> 1.5.12
 * [new tag]             1.5.13     -> 1.5.13
 * [new tag]             1.5.14     -> 1.5.14
 * [new tag]             1.5.2      -> 1.5.2
 * [new tag]             1.5.3      -> 1.5.3
 * [new tag]             1.5.4      -> 1.5.4
 * [new tag]             1.5.5      -> 1.5.5
 * [new tag]             1.5.6      -> 1.5.6
 * [new tag]             1.5.7      -> 1.5.7
 * [new tag]             1.5.8      -> 1.5.8
 * [new tag]             1.5.9      -> 1.5.9
 * [new tag]             1.6.0      -> 1.6.0
 * [new tag]             1.6.1      -> 1.6.1
 * [new tag]             1.6.2      -> 1.6.2
 * [new tag]             1.6.3      -> 1.6.3
HEAD is now at d14d0c25d Merge pull request #4143 from MikeMcQuaid/portable-ruby-2.3.3_2
==> Downloading https://homebrew.bintray.com/bottles-portable-ruby/portable-ruby-2.3.3_2.leopard_64.bottle.tar.gz
######################################################################## 100.0%
==> Pouring portable-ruby-2.3.3_2.leopard_64.bottle.tar.gz
==> Tapping homebrew/core
Cloning into '/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core'...
remote: Counting objects: 4744, done.
remote: Compressing objects: 100% (4540/4540), done.
remote: Total 4744 (delta 55), reused 615 (delta 17), pack-reused 0
Receiving objects: 100% (4744/4744), 3.84 MiB | 1.19 MiB/s, done.
Resolving deltas: 100% (55/55), done.
Tapped 4540 formulae (4,786 files, 12MB)
==> Cleaning up /Library/Caches/Homebrew...
==> Migrating /Library/Caches/Homebrew to /Users/mgr206/Library/Caches/Homebrew...
==> Deleting /Library/Caches/Homebrew...
Already up-to-date.
==> Installation successful!

==> Homebrew has enabled anonymous aggregate user behaviour analytics.
Read the analytics documentation (and how to opt-out) here:
  https://docs.brew.sh/Analytics.html

==> Next steps:
- Run `brew help` to get started
- Further documentation: 
    https://docs.brew.sh


예, 이제 설치가 완료됩니다.

openssl 업데이트



MacBook Pro의 openssl 버전이 너무 오래되어 다양한 문제가 발생하여 업데이트합니다.
MacBook-Pro:tools mgr206$ brew install openssl
==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2o_1.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring openssl-1.0.2o_1.sierra.bottle.tar.gz
==> Caveats
A CA file has been bootstrapped using certificates from the SystemRoots
keychain. To add additional certificates (e.g. the certificates added in
the System keychain), 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,
because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries.

If you need to have this software first in your PATH run:
  echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile

For compilers to find this software you may need to set:
    LDFLAGS:  -L/usr/local/opt/openssl/lib
    CPPFLAGS: -I/usr/local/opt/openssl/include

==> Summary
🍺  /usr/local/Cellar/openssl/1.0.2o_1: 1,791 files, 12.3MB
MacBook-Pro:tools mgr206$ openssl version
OpenSSL 0.9.8zh 14 Jan 2016


버전 업 실패?



설치 후 버전을 확인하면 0.9.8zh에서 변경되지 않았습니다.
MacBook-Pro:bin mgr206$ which openssl
/usr/bin/openssl

brew로 openssl을 설치했으므로 확인해 보겠습니다.
MacBook-Pro:bin mgr206$ which openssl
/usr/bin/openssl
MacBook-Pro:bin mgr206$ brew list openssl
/usr/local/Cellar/openssl/1.0.2o_1/.bottle/etc/ (8 files)
/usr/local/Cellar/openssl/1.0.2o_1/bin/c_rehash
/usr/local/Cellar/openssl/1.0.2o_1/bin/openssl
/usr/local/Cellar/openssl/1.0.2o_1/include/openssl/ (74 files)
/usr/local/Cellar/openssl/1.0.2o_1/lib/libcrypto.1.0.0.dylib
/usr/local/Cellar/openssl/1.0.2o_1/lib/libssl.1.0.0.dylib
/usr/local/Cellar/openssl/1.0.2o_1/lib/engines/ (12 files)
/usr/local/Cellar/openssl/1.0.2o_1/lib/pkgconfig/ (3 files)
/usr/local/Cellar/openssl/1.0.2o_1/lib/ (4 other files)
/usr/local/Cellar/openssl/1.0.2o_1/share/man/ (1680 files)

PATH 수정



웹에서 살펴보면 $brew link openssl로 링크한다는 기사도 있었지만 내 환경에서는 오류가 발생했습니다.
MacBook-Pro:/ mgr206$ brew link openssl --force
Warning: Refusing to link: openssl
Linking keg-only openssl means you may end up linking against the insecure,
deprecated system OpenSSL while using the headers from Homebrew's openssl.
Instead, pass the full include/library paths to your compiler e.g.:
  -I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib

그래서 .bash_profile에 PATH를 설정합니다. PATH는/usr/local/opt/openssl/bin입니다.
.bash_profile이 없었기 때문에 만듭니다.
MacBook-Pro:/ mgr206$ sudo touch .bash_profile
Password:
MacBook-Pro:/ mgr206$ ls -la
・
・
-rw-r--r--   1 root        wheel         0  5  3 20:57 .bash_profile
・
・

파일이 생겼으므로 PATH를 설정합니다.
MacBook-Pro:/ mgr206$ echo 'export PATH=/usr/local/opt/openssl/bin:$PATH' >> ~/.bash_profile
MacBook-Pro:/ mgr206$ source .bash_profile

확인



brew로 설치한 openssl의 PATH와 버전입니다.
MacBook-Pro:/ mgr206$ which openssl
/usr/local/opt/openssl/bin/openssl
MacBook-Pro:/ mgr206$ openssl version
OpenSSL 1.0.2o  27 Mar 2018