我在使用 net/http
包访问 https
url 时遇到问题。
这是错误的工作示例:
package main
import (
"fmt"
"net/http"
)
func main() {
_, err := http.Get("https://api.bitfinex.com/v1/book/ltcbtc")
if err != nil {
fmt.Println(err)
}
}
这个程序产生错误,
Get https://api.bitfinex.com/v1/book/ltcbtc: crypto/rsa: verification error
docs对于 net/http
明确说明,
Get, Head, Post, and PostForm make HTTP (or HTTPS) requests
但我找不到关于此错误的任何文档。
source对于 crypto/rsa
只有这个关于错误的说法:
// ErrVerification represents a failure to verify a signature.
// It is deliberately vague to avoid adaptive attacks.
var ErrVerification = errors.New("crypto/rsa: verification error")
所以我不确定从这里去哪里。我很确定这不是他们的错,因为 Chrome 对他们的 https 证书很满意。
我也尝试过将 Client
与 tls.Config
一起使用,该 InsecureSkipVerify
设置为 true
,但这似乎并没有解决这个错误。
最佳答案
Go 使用linux 下的系统根SSL 证书和 windows .
鉴于测试在我的 ubuntu 12.04 盒子上运行良好,go 1.2,或者
- 您使用的是非常旧的 go 版本
- 您的系统有过时的根证书
如果您想更新您的根证书,here是Windows的提示。谷歌搜索应该会为您找到更多关于其他操作系统的想法。
关于https - 戈朗 : HTTPS request yields "crypto/rsa: verification error",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22407042/