英文:
golang: Send http request with certificate
问题
首先,我是新手在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,
},
}
}
但是结果我得到了local error: no renegotiation
。
谢谢任何帮助!
英文:
For first I am newbie in golang.
I try to send https request. I create http.Client like this:
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,
},
}
}
But as result I get local error: no renegotiation
.
Thanks for any help!
答案1
得分: 2
这可能是你正在访问的远程服务器的问题,但这是一个已知的问题(例如,Microsoft Azure服务中存在此问题)。
可能会有一个针对go1.4的解决方法,但在那之前,go客户端仍不支持TLS重新协商。
相关问题:https://code.google.com/p/go/issues/detail?id=5742
英文:
This is likely a problem with the remote server you're accessing, but it is a known problem (with Microsoft Azure services for one).
There may be a workaround on the way for go1.4, but until then the go client still doesn't support TLS renegotiation.
Relevant issue: https://code.google.com/p/go/issues/detail?id=5742
答案2
得分: 1
看起来重新协商(和客户端证书认证)以前是不支持的。这个问题似乎已经通过提交 https://github.com/golang/go/commit/af125a5193c75dd59307fcf1b26d885010ce8bfd 得到修复。
英文:
It looks as though renegotiation (and client certificate authentication) was previously unsupported. This looks to have been fixed by commit https://github.com/golang/go/commit/af125a5193c75dd59307fcf1b26d885010ce8bfd
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论