MacOS – how to make Mac use latest openssl instead of /System/Library/OpenSSL

macosopenssl

I just (in June 2016) ran the following instructions to update Openssl (in /usr/local/openssl) on my Mac, but when I check the version, it's showing that I'm using a version built in 2015 (the System/Library/OpenSSL version).

Question: what can I do to get my Mac (running El Capitain) to use the latest version I installed?

The commands I ran to use the latest version:

cd /usr/local/src
curl --remote-name https://www.openssl.org/source/openssl-1.0.2h.tar.gz
Extract the archive and move into the folder.

tar -xzvf openssl-1.0.2h.tar.gz
cd openssl-1.0.2h
Compile and Install
Configure, compile and install into /usr/local/openssl-1.0.2h.

./configure darwin64-x86_64-cc --prefix=/usr/local/openssl-1.0.2h
make depend
make
make install
Create a symbolic link that points /usr/local/openssl to /usr/local/openssl-1.0.2h.

ln -s openssl-1.0.2h /usr/local/openssl

When I run openssl version in the terminal, it shows me this output (the important part is that it was built in July 2015 and is the System/Library/Openssl)

openssl version -a
OpenSSL 0.9.8zg 14 July 2015
built on: Jul 31 2015
platform: darwin64-x86_64-llvm
options:  bn(64,64) md2(int) rc4(ptr,char) des(idx,cisc,16,int) blowfish(idx) 
compiler: -arch x86_64 -fmessage-length=0 -pipe -Wno-trigraphs -fpascal-strings -fasm-blocks -O3 -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -DL_ENDIAN -DMD32_REG_T=int -DOPENSSL_NO_IDEA -DOPENSSL_PIC -DOPENSSL_THREADS -DZLIB -mmacosx-version-min=10.6
OPENSSLDIR: "/System/Library/OpenSSL"

Best Answer

Determine where the binary file openssl is located.

find /usr/local -name 'openssl*' -exec ls -lFd {} + 

The binary file should have /bin/openssl* at the end of the absolute path. Also open a Finder window to view the file system in the GUI with the command

open /usr/local

Remove any symbolic links that you have created so far then make a new symbolic link to /usr/local/bin/openssl.

This thread also has helpful details on openssl options and managing your path to select an alternate version.