http - 获取 https ://<mydomain. com>/translate/2327496366232: x509: 证书由未知权威签署”

标签 http go https

在我的 Go 应用程序中,我调用了 Hostname+"/translate/12345
事情取决于环境,在本地 Hostname将在 http 上,在生产中,它将在 https

当我用 postman 在https上测试生产路线时,没有问题,路线工作正常。

但是当我从 WS 运行它时,我得到:

Get https://<mydomain.com>/translate/2327496366232: x509: certificate signed by unknown authority"

这是我的代码:
var terID string
client := http.Client{}
req, err := http.NewRequest("GET", Hostname+"/translate/"+terID, nil)
if err != nil {
    return "", err
}
req.SetBasicAuth(Username, Password)
res, err := client.Do(req)
if err != nil {
    return "", err
}

我能做些什么来解决这个问题?

最佳答案

根据https://github.com/andygrunwald/go-jira/issues/52 , 请试试

import ("net/http"; "crypto/tls")

tr := &http.Transport{
    TLSClientConfig: &tls.Config{InsecureSkipVerify : true},
}
client := &http.Client{Transport: tr}

关于http - 获取 https ://<mydomain. com>/translate/2327496366232: x509: 证书由未知权威签署”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56079696/

相关文章:

java - 如何在 Android 中使用 HTTPS 发布

rest - 我应该使用 POST 请求向我的服务器发送大量 ID 的检索请求吗?

rest - 对于不同的 http 方法,对于无效 URL 的请求返回哪种状态?

go - 在这种情况下不会出现 panic

go - 在Gohpish工具中创建新路线时遇到问题

css - Font Awesome 与 HTTPS

http - 使用具有适当名称的 Powershell 从 http 下载多个文件

javascript - 同源政策目的可疑

nginx - 使用 Nginx 部署多个 Go 应用程序

iis - 301 重写规则导致 SEO 警报