Go 发起请求 /转发请求 报错x509: certificate has expired or is not yet valid

700 阅读1分钟

场景:请求阿里云墨迹天气Api的时候,发现用PHP和测试工具都可以请求接口,唯独Go语言的不行!

报错:x509: certificate has expired or is not yet valid

解决方式:

//这里信任正式设置
Verify := &http.Transport{
   TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}

client := &http.Client{
   ...
   Transport: Verify,//这里添加
}