命令
go install -v golang.org/x/tools/cmd/godoc@latest
失败并显示消息
proxyconnect tcp:tls:第一条记录看起来不像TLS握手
我假设原因是我在一个公司代理后面,该代理不使用https从我的客户端(我的windows机器)到代理服务器的通信。proxy
和no_proxy
的windows用户环境变量C:\>reg query HKEY_CURRENT_USER\Environment
的设置如下
C:\>reg query HKEY_CURRENT_USER\Environment | findstr /R .PROXY.
HTTP_PROXY=http://myuser:[email protected]:port
HTTPS_PROXY=https://myuser:[email protected]:port
# i also tried http
# HTTPS_PROXY=http://myuser <-- no https
NO_PROXY=localhost,127.0.0.1,.mycomp.com,.foo.mycomp,localhost:5001
将HTTPS_PROXY
的值从https://myuser...
更改为http://myuser...
没有区别。用于http的git config git config -l
具有以下设置
C:\>git config -l | findstr /R http.
http.sslcainfo=C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
http.sslbackend=openssl
http.proxy=http://myuser:[email protected]:port
http.sslverify=false
https.proxy=http://myuser:[email protected]:port
更新
在this answer中,customDialContext
用于避免相同的错误消息proxyconnect tcp: tls: first record does not look like a TLS handshake
,但用于不同的任务(调用rest服务)。
// Custom dialing function to handle connections
func customDialContext(ctx context.Context, network, addr string) (net.Conn, error) {
conn, err := net.Dial(network, addr)
return conn, err
}
提问
我要怎么做
- 所以我可以使用
go install
- 并避免或忽略错误
proxyconnect tcp: tls: first record does not look like a TLS handshake
- 自定义拨号功能可以用于安装命令吗(参见上面的更新)?
1条答案
按热度按时间nnt7mjpx1#
在企业环境中,我建议使用
genotrance/px
--pac=file
option或者.ini pac
指令启动它。这意味着您的
HTTPS_PROXY
将变为http://127.0.0.1:3128
(不再是myuser:mypass
!)您的设置:
注意:
HTTPS_PROXY
通过HTTP引用相同的代理,* 而不是 * HTTPS。在
px.ini
中,只放server = http://my.corporate.proxy
(同样,仅限HTTP)。启动它一次(每个Windows会话),然后从CLI或Go程序尝试Internet连接。