升级OpenSSL后,ODBC无法找到正确的OpenSSL版本。

8

更新:如果你遇到了同样的问题,可以通过这里讨论问题的根源。


使用 homebrew 升级到 Python3.10 后,我的 OpenSSL 版本也升级到了版本 3。

现在我无法连接到 SQL Server,因为 ODBC 需要 OpenSSL 1.1 或 1.0。所以当我运行以下命令时:

isql -v -k "<connection string"

我遇到了以下错误:
[08001][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]
[08001][Microsoft][ODBC Driver 17 for SQL Server]Client unable to establish connection

但是当我查看 /usr/local/etc/ 目录时,发现已经安装了 openssl@1.1

openssl version

我该如何解决这个问题?我对此不是很熟悉。因此 ODBC 需要找到正确的 OpenSSL 版本,也就是 1.1。

我尝试过:

ln -s /usr/local/Cellar/openssl@1.1/1.1.1g /usr/local/opt/openssl

同时当我运行 openssl 命令时,它会找到正确的版本:
➜  ~ openssl
OpenSSL> version
OpenSSL 1.1.1l  24 Aug 2021
OpenSSL> 

输出 brew list openssl@1.1

/usr/local/Cellar/openssl@1.1/1.1.1l_1/.bottle/etc/ (7 files)
/usr/local/Cellar/openssl@1.1/1.1.1l_1/bin/c_rehash
/usr/local/Cellar/openssl@1.1/1.1.1l_1/bin/openssl
/usr/local/Cellar/openssl@1.1/1.1.1l_1/include/openssl/ (104 files)
/usr/local/Cellar/openssl@1.1/1.1.1l_1/lib/libcrypto.1.1.dylib
/usr/local/Cellar/openssl@1.1/1.1.1l_1/lib/libssl.1.1.dylib
/usr/local/Cellar/openssl@1.1/1.1.1l_1/lib/engines-1.1/ (2 files)
/usr/local/Cellar/openssl@1.1/1.1.1l_1/lib/pkgconfig/ (3 files)
/usr/local/Cellar/openssl@1.1/1.1.1l_1/lib/ (4 other files)
/usr/local/Cellar/openssl@1.1/1.1.1l_1/share/doc/ (3971 files)
/usr/local/Cellar/openssl@1.1/1.1.1l_1/share/man/ (3971 files)
➜  ~ 

ls -l /usr/local/opt/openssl/lib/libssl.dylib的输出结果:

lrwxr-xr-x  1 username  admin  14 Sep  7 13:46 /usr/local/opt/openssl/lib/libssl.dylib -> libssl.3.dylib

同时运行 DYLD_PRINT_LIBRARIES=1 isql -v -k "<connection string" 命令可以给出以下输出。似乎它仍然链接到 openssl@3

dyld: loaded:  /usr/local/opt/openssl/lib/libssl.dylib
dyld: loaded: /usr/local/Cellar/openssl@3/3.0.0/lib/libcrypto.3.dylib
[08001][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]
[08001][Microsoft][ODBC Driver 17 for SQL Server]Client unable to establish connection
[ISQL]ERROR: Could not SQLDriverConnect

1.1.1g相当老了。请使用brew list openssl@1.1ls -l /usr/local/opt/openssl/lib/libssl.dylib命令的输出编辑您的问题。 - AlwaysLearning
当然,已经添加了两个输出 @AlwaysLearning - Erfan
@AlwaysLearning 有什么想法吗?我已经尝试了我能找到的一切。 - Erfan
3个回答

15

在尝试了许多方法后,我找到了一个(hacky)的解决方案:

  1. 我删除了/usr/local/opt/中的链接:
rm openssl
  1. 创建了一个到openssl@1.1的新链接
ln -s /usr/local/Cellar/openssl@1.1/1.1.1l_1 /usr/local/opt/openssl

1
这也正在GitHub上讨论此处 - Gord Thompson
这里链接到这里 - KT12
我收到了 ln: /usr/local/opt/openssl: No such file or directory 的错误信息。如何修复这个问题?以及/usr/bin/openssl - Fyzzys
这最终对我起作用了! - Ali Vaseghnia

0

我不确定你删除了哪个链接,因为我在下面的链接中都有

ls /usr/local/opt: -openssl -openssl@1.1 -openssl@3

你是否删除了 /usr/local/opt/openssl?我们应该怎么处理 /usr/local/opt/openssl@1.1 和 /usr/local/opt/openssl@3?我们应该保留它们吗?

此外,我在 /usr/local/opt/openssl@1.1 中没有看到 1.1.1l_1。

我尝试了这个命令: ln -s /usr/local/Cellar/openssl@1.1/1.1.1l_1 /usr/local/opt/openssl 这是我得到的回复,但问题仍然存在: ln: /usr/local/opt/openssl: File exists

谢谢


这不是一个有助于原问题的答案。如果您有类似的问题,请随意开启一个新的问题,以便从社区中获得帮助。 - Ali Briceño

0
你尝试重新安装msodbcsql17了吗?
旧版本的msodbcsql17报告依赖于OpenSSL 1.1:
$ brew deps -n msodbcsql17
m4
libtool
unixodbc
openssl@1.1

重新安装 msodbcsql17...

$ brew reinstall msodbcsql17
==> Downloading https://ghcr.io/v2/homebrew/core/openssl/3/manifests/3.0.0
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/openssl/3/blobs/sha256:ec819e57038f4ae11e3a3e083ec1d37c174e44fce08830bd
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:ec819e57038f4ae11e3a3e083ec1d37c174
######################################################################## 100.0%
==> Downloading https://download.microsoft.com/download/1/9/A/19AF548A-6DD3-4B48-88DC-724E9ABCEB9A/msodbcsql17-17.8.1.1-
==> Reinstalling microsoft/mssql-release/msodbcsql17 
==> Installing dependencies for microsoft/mssql-release/msodbcsql17: openssl
==> Installing microsoft/mssql-release/msodbcsql17 dependency: openssl
==> Pouring openssl@3--3.0.0.catalina.bottle.tar.gz
==> Regenerating CA certificate bundle from keychain, this may take a while...
  /usr/local/Cellar/openssl@3/3.0.0: 6,415 files, 28.2MB
==> Installing microsoft/mssql-release/msodbcsql17
The license terms for this product can be downloaded from
https://aka.ms/odbc17eula and found in
/usr/local/share/doc/msodbcsql17/LICENSE.txt . By entering 'YES',
you indicate that you accept the license terms.
Do you accept the license terms? (Enter YES or NO)
YES
==> odbcinst -u -d -n "ODBC Driver 17 for SQL Server"
==> odbcinst -i -d -f ./odbcinst.ini
  /usr/local/Cellar/msodbcsql17/17.8.1.1: 10 files, 2MB, built in 9 seconds

在重新安装或升级msodbcsql17后,现在报告OpenSSL 3为依赖项:

$ brew deps -n msodbcsql17
m4
libtool
unixodbc
openssl@3

我已经尝试过了,但仍然出现相同的错误:“无法加载OpenSSL库,请确保已安装OpenSSL 1.0或1.1”。 - Erfan
我在我的问题中添加了更多信息,似乎ODBC找不到openssl1.1。 - Erfan
@Erfan,那应该解决了。which openssl 返回什么? - AlwaysLearning
返回 /usr/local/opt/openssl@3/bin/openssl - Erfan

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接