Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update OpenSSL on mac?

I need to ensure that I have OpenSSL version of 1.0.1 or greater to connect to the Salesforce API according to this documentation.

According to this question, I can do the following steps (which I've completed successfully)

  1. brew update
  2. brew install openssl
  3. brew link --force openssl

When I run openssl version -a, I get the following:

OpenSSL 1.0.2h  3 May 2016
built on: reproducible build, date unspecified
platform: darwin64-x86_64-cc
options:  bn(64,64) rc4(ptr,int) des(idx,cisc,16,int) idea(int) blowfish(idx) 
compiler: /usr/bin/clang -I. -I.. -I../include  -fPIC -fno-common -DOPENSSL_PIC -DZLIB -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H -arch x86_64 -O3 -DL_ENDIAN -Wall -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DECP_NISTZ256_ASM
OPENSSLDIR: "/opt/local/etc/openssl"

However, when I run python -c "import ssl; print ssl.OPENSSL_VERSION", I get the following:

OpenSSL 0.9.8zh 14 Jan 2016

I'm getting mixed signals from my computer, but my salesforce module is still not working, so I know OpenSSL is not updated completely on my computer.

I should also mention that I've also tried:

sudo port upgrade openssl

Port seemed to have worked, but when I run python -c "import ssl; print ssl.OPENSSL_VERSION" I still get that I'm on "OpenSSL 0.9.8zh"

Is there another way to update OpenSSL?

like image 540
Chris Avatar asked Jul 19 '16 20:07

Chris


People also ask

Do I need to install OpenSSL on Mac?

Whether you are building apps for just macOS or for cross-platform, if your app is using OpenSSL for crypto-works, you will have to install OpenSSL library since macOS ships with LibreSSL. Furthermore, cross-platform cryptography in .

Is OpenSSL available for Mac?

OpenSSL provides support for the TLS and SSL protocols and also includes various tools used in cryptography. Note that OpenSSL is officially available only as source, so you must manually compile and install the software on your Mac.


2 Answers

I think this is a multi-part issue with the versions of Python you are using and your $PATH variable.

First check where you're looking for Python by using this command in the terminal:

which python

It should output something like this: /usr/local/bin/python

Then check for the path that you have setup.

echo $PATH

Likely you're seeing something like:

/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/username/anaconda/bin:/usr/bin:/bin:/usr/sbin:/sbin

The issue is probably that the version of python tied to your default when you enter python in your terminal is not one that has the modern version of openssl.

In other words:

openssl version -a

Is checking for openssl somewhere different than

python -c "import ssl; print ssl.OPENSSL_VERSION"

To fix this, you might try editing your $PATH variable.

I suggest doing this by editing something like your ~/.bash_profile file. You can add something like this to specify a different Python binary to use:

export PATH="/usr/local/bin:$PATH"

Plop this on the end of your .bash_profile file and then whenever you're using bash it should look for Python in the /usr/local/bin directory before looking elsewhere. Keep in mind that this might also affect places that other programs look for Python (or other binaries).

like image 186
Fernando Avatar answered Oct 23 '22 13:10

Fernando


@fernando's answer had the right theory but his recommendation for a next step didn't work for me, because /usr/local/bin was already first in my $PATH. Here's how I fixed mine:

In the response for brew info python I saw:

==> Caveats This formula installs a python2 executable to /usr/local/bin. If you wish to have this formula's python executable in your PATH then add the following to ~/.bash_profile: export PATH="/usr/local/opt/python/libexec/bin:$PATH"

I added that last line to my ~/.bash_profile, opened a new terminal window, and it worked.

like image 45
meetar Avatar answered Oct 23 '22 15:10

meetar