×

debug 一次诡异的 curl 出错:curl: (35) LibreSSL SSL_connect: SSL_ERROR_SYSCALL 最后原因令我意想不到

2023-04-28 13:22:15 Falcon

用 homebrew 安装一个应用,据说homebrew 4.0之后需要请求 https://formulae.brew.sh/api/formula.jws.json 以获得全部软件的信息,这个列表很大,据说有300多M,但不是重点。重点是执行安装时可以看到homebrew会使用curl请求,然后报错:

brew install localsend
==> Downloading https://formulae.brew.sh/api/formula.jws.json
curl: (35) LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to formulae.brew.sh:443

Error: Failure while executing; `/usr/bin/env /opt/homebrew/Library/Homebrew/shims/shared/curl --cookie /dev/null --globoff --user-agent Homebrew/4.0.9\ \(Macintosh\;\ arm64\ Mac\ OS\ X\ 12.6.1\)\ curl/7.79.1 --header Accept-Language:\ en --fail --progress-bar --location --remote-time --output /Users/falcon/Library/Caches/Homebrew/api/formula.jws.json --compressed --speed-limit 100 --speed-time 5 --progress-bar https://formulae.brew.sh/api/formula.jws.json` exited with 35. Here's the output:
curl: (35) LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to formulae.brew.sh:443

我最开始以为是墙的问题,但设置代理后依然报错,直接用curl 加上  -k 也报同样的错误:

curl: (35) LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to formulae.brew.sh:443

我开始怀疑是证书的问题,执行以下命令检查。

openssl s_client -connect formulae.brew.sh:443

结果如下:

.....

    Verify return code: 20 (unable to get local issuer certificate)
    Extended master secret: no
    Max Early Data: 0
---
read R BLOCK


从lets encrypt下载根证书 ,然后加入系统信任,依然同样的错误。

如果不是证书的问题,我觉得会不会是openssl的问题,执行

which -a openssl
/usr/local/opt/openresty-openssl111/bin/openssl
/usr/bin/openssl

可以看到有两个版本的openssl,并且openresty绑定的openssl 优先使用,也就是实际用的版本,再看版本是1.1.1i,2020年11月的版本。

/usr/local/opt/openresty-openssl111/bin/openssl version -a
OpenSSL 1.1.1i  8 Dec 2020
built on: Wed Apr 14 10:37:09 2021 UTC
platform: darwin64-x86_64-cc
options:  bn(64,64) rc4(16x,int) des(int) idea(int) blowfish(ptr)
compiler: clang -fPIC -arch x86_64 -O3 -Wall -g -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DRC4_ASM -DMD5_ASM -DAESNI_ASM -DVPAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DX25519_ASM -DPOLY1305_ASM -DZLIB -DNDEBUG
OPENSSLDIR: "/usr/local/etc/openssl@1.1.1"
ENGINESDIR: "/usr/local/Cellar/openresty-openssl111/1.1.1i_2/lib/engines-1.1"
Seeding source: os-specific

如果看/usr/bin/openssl,则是:

LibreSSL 2.8.3
built on: date not available
platform: information not available
options:  bn(64,64) rc4(ptr,int) des(idx,cisc,16,int) blowfish(idx)
compiler: information not available
OPENSSLDIR: "/private/etc/ssl"

为什么openresty的版本会在最前面? 原因是我在 ~/.zshrc 里把 $PATH 变量中把 /usr/local/opt/openresty-openssl111/bin 放在了 /usr/bin 前面 !!!

调整后重新执行 . ~/.zshrc 就正常了。

本文收录于