我正在使用可通过 HTTPS 访问的公司托管 (Bitbucket) git 存储库。使用 macOS 11 (Big Sur) 可以访问它(例如git fetch
),但在更新到 macOS 12 Monterey 后中断。*
在将 macOS 更新到 12 Monterey 之后,我之前的 git 设置坏了。现在我收到以下错误消息:
$ git fetch
fatal: unable to access 'https://.../':
error:06FFF089:digital envelope routines:CRYPTO_internal:bad key length
对于它的价值, usingcurl
也不起作用:
$ 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 用户)以接受服务器的证书?