Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mac M1 SQL Server SQLSrv OpenSSL library could not be loaded, make sure OpenSSL 1.0 or 1.1 is installed

I just bought a M1 Mac mini running Big Sur 11.6, I've installed PHP 7.3, msodbcsql17, mssql-tools, sqlsrv and pdo_sqlsrv.

But when I try to connect using sqlsrv, the following error happens [Microsoft][ODBC Driver 17 for SQL Server]SSL Provider: [OpenSSL library could not be loaded, make sure OpenSSL 1.0 or 1.1 is installed]

I've installed [email protected] via brew and my profile contains

export PATH="/opt/homebrew/opt/[email protected]/bin:$PATH"

It seems like PHP is using the correct version, when printing echo OPENSSL_VERSION_TEXT, it says OpenSSL 1.1.1l 24 Aug 2021

I'm not sure what else to try, to make it work?

like image 564
Jamie B Avatar asked Dec 18 '25 16:12

Jamie B


2 Answers

For M1 Mac, the default location of brew install is /opt/homebrew, instead of /usr/local. Please refer to this link. Therefore, the symlink you need to add/change is:

ln -sfn /opt/homebrew/Cellar/[email protected]/1.1.1m /opt/homebrew/opt/openssl

Using option -f as you're forcing to replace the link, while using -n as the source link is a directory. Of course, change the version if your openssl is not 1.1.1m.

like image 122
wsnyy0611 Avatar answered Dec 21 '25 06:12

wsnyy0611


I had the same "OpenSSL library could not be loaded" error today (on an Intel Mac) when trying to connect via isql. (Also, using python, as pyodbc error '08001': ODBC Driver 17 for SQL Server client unable to establish connection).

Apparently, as of early October 2021, the latest SQL Server ODBC Driver is not compatible with the latest version 3 of OpenSSL.

See: https://github.com/microsoft/homebrew-mssql-release/issues/59.

Diagnosis: Check which OpenSSL version is being called via:

ls -l /usr/local/opt/openssl/lib 

You should see an entry for OpenSSL 1.0 or 1.1 (eg libssl.dylib -> libssl.1.1.dylib); when I was having this issue it showed libssl.dylib -> libssl.3.dylib.

The workaround is just to create a symlink. (Use "brew info [email protected]" to check the filename/path.) For example:

ln -s /usr/local/Cellar/[email protected]/1.1.1l_1 /usr/local/opt/openssl
like image 36
azuma Avatar answered Dec 21 '25 05:12

azuma



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!