28

In my mac version 10.15.5, openssl is still pointing to LibreSSL 2.8.3. I have used the below commands, but no luck

homebrew install libressl

After installation when I ran the version command it is still showing LibreSSL 2.8.3 Also below command is throwing error -

brew link --force openssl                                                
Warning: Refusing to link macOS provided/shadowed software: openssl@1.1
If you need to have openssl@1.1 first in your PATH run:
  echo 'export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"' >> ~/.zshrc

For compilers to find openssl@1.1 you may need to set:
  export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
  export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"
Sudipta Deb
  • 465
  • 1
  • 4
  • 10

3 Answers3

23

You may already have this working. To test run: which openssl

Further, running this will advise which version is the default: openssl version

To change to the homebrew version you need to add it into the path before the default. To do this, edit the startup script for your shell (which it seems in your case is zsh). So in your case edit ~/.zshrc with your favorite text editor or something like: nano ~/.zshrc

(for the default bash shell, use nano ~/.bashrc)

Insert a command to add the path to the brew installed OpenSSL using this line, preferably somewhere near the top of the file:

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

(At the time of writing the most recent version of OpenSSL has moved onto 1.1.1, so it may need to look like this now export PATH="/usr/local/opt/openssl@1.1.1/bin:$PATH")

Then "reload" the zsh startup script with this command:

source ~/.zshrc

You should now be seeing openssl 1.1 (no longer libressl) when running which openssl or openssl version

Saikat
  • 14,222
  • 20
  • 104
  • 125
Roy Verrips
  • 371
  • 1
  • 3
  • This works properly - `export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"`, which correctly returns latest `1.1.1i` (at time of comment) on `openssl version` – 10623169 Jan 04 '21 at 16:30
  • 3
    On my mac `/usr/local/opt/openssl` is a symlink to `../Cellar/openssl@1.1/1.1.1j` so in order to automatically point to an updated version of `openssl` it's better to `export PATH="/usr/local/opt/openssl/bin:$PATH"` – Marcello Romani Mar 18 '21 at 14:10
12

For users with Apple M1 silicon OpenSSL installed by brew has a different location. You should add a line export PATH="/opt/homebrew/opt/openssl@1.1/bin:$PATH" at ~/.zshrc file

4

So for me, openssl version used to be LibreSSL 2.8.3. Doing export PATH="/usr/local/opt/openssl@1.1/bin:$PATH" only got it to show OpenSSL 1.1.1i in the terminal, and also which openssl gives me the right command, but it still doesn't work.

So then adding the line export PATH="/usr/local/opt/openssl@1.1/bin:$PATH" inside ~/.profile worked.

Not ~/.bash_profile if you are using bash, or ~/.zshrc, or /etc/paths.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Onion
  • 85
  • 1
  • 9