'On macOS Big Sur, how do I get the version of OpenSSL installed through Homebrew to be what is used on the command line?

I’m on macOS Big Sur. I installed OpenSSL via Homebrew like this:

$ brew install openssl
Updating Homebrew...
==> Auto-updated Homebrew!
Updated Homebrew from 40a7a0119 to f50b87031.
Updated 2 taps (homebrew/core and homebrew/cask).
==> Updated Formulae
Updated 24 formulae.
==> Updated Casks
Updated 19 casks.

Warning: [email protected] 1.1.1l is already installed and up-to-date.
To reinstall 1.1.1l, run:
  brew reinstall [email protected]
DIG139:cfs-web davea$ brew reinstall openssl
==> Downloading https://ghcr.io/v2/homebrew/core/openssl/1.1/manifests/1.1.1l
Already downloaded: /Users/davea/Library/Caches/Homebrew/downloads/7cb540b15662ae88caf307947df0254e5c64c04933630f7e9543cb018107ecbe--openssl@1.1-1.1.1l.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/openssl/1.1/blobs/sha256:ff8b2a965c680b4d9baccd60e799d0989e7dc562d2ba81696
Already downloaded: /Users/davea/Library/Caches/Homebrew/downloads/b6c57e7f9acfe19e13efdfa925e9d77bbc52f6965e0f48326f64f73d18ef9c81--openssl@1.1--1.1.1l.big_sur.bottle.tar.gz
==> Reinstalling [email protected] 
==> Pouring [email protected]_sur.bottle.tar.gz
==> Regenerating CA certificate bundle from keychain, this may take a while...
🍺  /usr/local/Cellar/[email protected]/1.1.1l: 8,073 files, 18.5MB
Removing: /usr/local/Cellar/[email protected]/1.1.1k... (8,071 files, 18.5MB)
Removing: /Users/davea/Library/Caches/Homebrew/[email protected]... (5.4MB)

The above seems to imply I have already installed version 1.1.1, but when I check on the command line, I see the following:

$ openssl version
LibreSSL 2.8.3
$ which openssl
/usr/bin/openssl

Where is this newer version of OpenSSL coming from and how can I make the versions consistent on my machine?



Solution 1:[1]

You could add something like this to your shell so that your environment picks up brew version.

export PATH="/usr/local/opt/openssl@1/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/openssl@1/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@1/include"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Paul