我需要创建一个返回自签名代理http.Client的函数,但找不到任何有效的解决方案。
我正在附加当前似乎无效的代码。
func CreateProxyClient(server string,serverProxy string, sid string, portProxy int) (*Client, error) {
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
proxyURL, _ := url.Parse("http://" + serverProxy+":"+strconv.Itoa(portProxy) )
http.DefaultTransport = &http.Transport{
Proxy: http.ProxyURL(proxyURL),
}
var netClient = &http.Client{
Timeout: time.Second * 1,
}
resp, _ := http.Get("http://"+server+":443")
fmt.Printf("%d",resp.StatusCode)
return &Client{netClient, server, sid, "", ""}, nil
}
我
答案 0 :(得分:0)
将此添加到http.Transport:
TLSNextProto: make(map[string]func(authority string, c *tls.Conn) http.RoundTripper),