for me, adding these lines to my .zshrc
file fixed it completely:
export LDFLAGS="-L/usr/local/opt/[email protected]/lib"
export CPPFLAGS="-I/usr/local/opt/[email protected]/include"
export PKG_CONFIG_PATH="PKG_CONFIG_PATH:/usr/local/opt/[email protected]/lib/pkgconfig"
These lines were in the comments when I ran brew link openssl
It also turned out I had an existing PKG_CONFIG_PATH line set for a previous version of openssl, so I removed that.