golang:发送带有证书的 http 请求

Ser*_*yak 5 https go

首先,我是 golang 的新手。

我尝试发送 https 请求。我像这样创建 http.Client:

func httpClient(c *Config) (httpClient *http.Client) {
cert, _ := tls.LoadX509KeyPair(c.CertFile, c.KeyFile)

ssl := &tls.Config{
    Certificates:       []tls.Certificate{cert},
    InsecureSkipVerify: true,
}

ssl.Rand = rand.Reader
return &http.Client{
    Transport: &http.Transport{
        TLSClientConfig: ssl,
    },
}
}
Run Code Online (Sandbox Code Playgroud)

但结果我得到local error: no renegotiation.

谢谢你的帮助!

Jim*_*imB 2

这可能是您正在访问的远程服务器的问题,但这是一个已知问题(其中之一是 Microsoft Azure 服务)。

go1.4 可能会有一个解决方法,但在此之前,go 客户端仍然不支持 TLS 重新协商。

相关问题:https://code.google.com/p/go/issues/detail? id=5742