LibreSSL SSL_read: SSL_ERROR_SYSCALL git 代理引发失败

背景

鼓捣了一套新的方案,在命令行里想出国,写到了脚本函数里,这之后就遇到 git pull | push 都报错(LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 60),于是开始排查问题

发现问题

git push
fatal: unable to access 'https://github.com/XXX/XXX.git/': LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to 127.0.0.1:8001

git pull
fatal: unable to access 'https://github.com/XXX/XXX.git/': LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to 127.0.0.1:8001

然后直接 github 也不行:

查看配置

因为不是新方案嘛,加了新的环境变量代理,就走不通,我的配置如下:

export http_proxy=http://127.0.0.1:8001;
export https_proxy=https://127.0.0.1:8001;

发现问题

根据报错情况来看,是 8001 端口不通,但是梯子代理明明是 8001,再仔细一看,原来是粗心了,本地只代理了http=> 8001 ,没有 https 代理,我的配置应该是将 https 的请求也通过 http://127.0.0.1:8001来代理出去,至此修改环境变量配置:

export https_proxy=http://127.0.0.1:8001;

解决问题且验证

总结

  • 除了仔细排查日志,还建议做回归验证,保证确实是某个 case 引起的问题。
  • 理解代理的作用和使用场景
  • 规范配置化信息格式,经常梳理,我把写好的 shell 函数放到下面,大家可以拿来参考。

# 终端代理配置 开启后每次打开终端都生效
function proxy {
        if [[ $1 = "on" ]]; then
                export http_proxy=http://127.0.0.1:8001
                        export https_proxy=http://127.0.0.1:8001
                        # 验证当前 ip 信息
                        curl ifconfig.co
                        echo -e "已开启代理" http_proxy=$http_proxy https_proxy=$https_proxy

        elif [[ $1 = "off" ]]; then
                        unset http_proxy
                        unset https_proxy
                        git config --global --unset http.proxy
                        git config --global --unset https.proxy
                        echo -e "已关闭代理"
        elif [[ $1 = "git" ]]; then
                        git config --global http.proxy 'https://127.0.0.1:8001'
                        git config --global https.proxy 'https://127.0.0.1:8001'
                        echo -e "已经开启 git"
        elif [[ $1 = "gitsock" ]]; then
                        git config --global http.proxy 'socks://localhost:1080'
                        git config --global https.proxy 'socks://localhost:1080'
                        echo -e "已经开启 gitsock!"
        else
                echo -n "Usage: proxy [on|off|git] "
        fi
}

参考 github issue https://github.com/libressl-portable/portable/issues/369

原文地址:https://www.cnblogs.com/darrenzzy/p/14903741.html