Openssl key generation on OS X failing

I have solved the issue with many google searches and consultation with a colleague who has also recently moved to a mac.

The symlinks for the new openssl where not created when homebrew did the installation. If you run brew link openssl you will receive the following message Warning: openssl is keg-only and must be linked with --force

This leads the the solution. Homebrew needs to be explicitly told to create the correct links.

brew link --force openssl

If you now check which openssl you will notice it points to the brew installed version /usr/local/bin/openssl


This worked for me on Montery (12.2)

brew install openssl
brew link openssl # outputs :

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

For compilers to find openssl@3 you may need to set:
  export LDFLAGS="-L/usr/local/opt/openssl@3/lib"
  export CPPFLAGS="-I/usr/local/opt/openssl@3/include"

For pkg-config to find openssl@3 you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/openssl@3/lib/pkgconfig"

I was just using the command so I did :

echo 'export PATH="/usr/local/opt/openssl@3/bin:$PATH"' >> ~/.zshrc

That worked, old output :

➜  ca git:(master) openssl version
LibreSSL 2.8.3

After:

➜  ca git:(master) source ~/.zshrc
➜  ca git:(master) openssl version
OpenSSL 3.0.1 14 Dec 2021 (Library: OpenSSL 3.0.1 14 Dec 2021)

Note : the other options that may be needed depending on your needs. Note 2 : my default shell is zsh, add it to your bashrc if you use bash, or to your shell of choice and it's PATH.