【发布时间】:2021-12-12 12:12:23
【问题描述】:
我正在使用可通过 HTTPS 访问的公司托管 (Bitbucket) git 存储库。访问它(例如git fetch)使用 macOS 11(Big Sur)工作,但在更新到 macOS 12 Monterey 后中断。
*
在将 macOS 更新到 12 Monterey 之后,我之前的 git 设置坏了。现在我收到以下错误消息:
$ git fetch
fatal: unable to access 'https://.../':
error:06FFF089:digital envelope routines:CRYPTO_internal:bad key length
不管怎样,使用curl 也不起作用:
$ curl --insecure -L -v https://...
* Trying ...
* Connected to ... (...) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: /etc/ssl/cert.pem
* CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* error:06FFF089:digital envelope routines:CRYPTO_internal:bad key length
* Closing connection 0
curl: (35) error:06FFF089:digital envelope routines:CRYPTO_internal:bad key length
通过 Safari 或 Firefox 访问相同的 HTTPS 源是可行的。
据我了解,底层错误“bad key length”错误来自OpenSSL/LibreSSL,这与 git 和 curl 在操作系统升级后失败是一致的。
这是 openssl 的输出:
$ openssl s_client -servername ... -connect ...:443
CONNECTED(00000005)
depth=2 C = US, O = DigiCert Inc, OU = www.digicert.com, CN = DigiCert Global Root G2
verify return:1
depth=1 C = US, O = DigiCert Inc, OU = www.digicert.com, CN = Thawte TLS RSA CA G1
verify return:1
depth=0 ...
4593010348:error:06FFF089:digital envelope routines:CRYPTO_internal:bad key length:
/System/Volumes/Data/SWE/macOS/BuildRoots/b8ff8433dc/Library/Caches/com.apple.xbs
/Sources/libressl/libressl-75/libressl-2.8/crypto/apple/hmac/hmac.c:188:
---
Certificate chain
...
---
No client certificate CA names sent
Server Temp Key: DH, 2048 bits
---
SSL handshake has read 4105 bytes and written 318 bytes
---
New, TLSv1/SSLv3, Cipher is DHE-RSA-AES256-GCM-SHA384
Server public key is 4096 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
SSL-Session:
Protocol : TLSv1.2
Cipher : DHE-RSA-AES256-GCM-SHA384
Session-ID: 1FA062DC9EEC9A310FF8231F1EB11A3BD6E0778F7AB6E98EAD1020A44CF1A407
Session-ID-ctx:
Master-Key:
Start Time: 1635319904
Timeout : 7200 (sec)
Verify return code: 0 (ok)
---
我确实尝试将服务器的证书添加到自定义 pem 文件中并设置 http.sslCAInfo,但这不起作用。作为一种解决方法,我目前正在使用解密/重新加密 HTTPS 流量的代理。
如何配置 git(或所有 LibreSSL 用户)以接受服务器的证书?
【问题讨论】:
-
我不知道,但尽管出现错误消息,但至少
openssl s_client -servername ... -connect ...:443实际上成功完成了 TLS 握手。如果只是为了尝试隔离问题,我会使用不同的最新版本的 openssl 再次尝试此操作。 -
@PresidentJamesK.Polk 作为罪魁祸首的 SSL 库与操作系统升级后出现的问题一致。但是,这也使得更改 SSL 库变得困难:如您所见,库本身位于
/Library/Caches内部,即 dyld_shared_cache,这使得更改非常棘手 -
只有 LibreSSL(不是 OpenSSL)使用函数 FFF=CRYPTO_internal。尽管 OpenSSL 已经定义了这个原因很长一段时间,但 AFAICT 直到 1.1.1d(Libre 分叉之后)才使用它,然后仅用于 RC5(未在 SSL/TLS 中使用)。 Libre 确实将它用于 HMAC,如命令行中的错误详细信息所示,但路径 crypto/apple/hmac/ 表明 Apple 已以可能错误的方式对其进行了修改。它绝对与服务器证书无关。 eBuccaneer 的方法可能通过使用未由苹果修改的 brew 中的 openssl 来工作。
标签: ssl openssl macos-monterey