如何为golang添加可信证书

Kin*_*arō 9 ssl ssl-certificate go

我正在尝试使用 go get 或 godep 为我的项目提取一些依赖项,但我在我的 mac 中看到了这一点

\n\n
KALEI-M-V11L:election kalei$ dep ensure\nThe following issues were found in Gopkg.toml:\n\n  \xe2\x9c\x97 unable to deduce repository and source type for "k8s.io/apiextensions-apiserver": unable to read metadata: unable to fetch raw metadata: failed HTTP request to URL "http://k8s.io/apiextensions-apiserver?go-get=1": Get https://k8s.io/apiextensions-apiserver?go-get=1: x509: certificate signed by unknown authority\n  \xe2\x9c\x97 unable to deduce repository and source type for "k8s.io/apimachinery": unable to read metadata: unable to fetch raw metadata: failed HTTP request to URL "http://k8s.io/apimachinery?go-get=1": Get https://k8s.io/apimachinery?go-get=1: x509: certificate signed by unknown authority\n  \xe2\x9c\x97 unable to deduce repository and source type for "k8s.io/client-go": unable to read metadata: unable to fetch raw metadata: failed HTTP request to URL "http://k8s.io/client-go?go-get=1": Get https://k8s.io/client-go?go-get=1: x509: certificate signed by unknown authority\n  \xe2\x9c\x97 unable to deduce repository and source type for "sigs.k8s.io/controller-runtime": unable to read metadata: unable to fetch raw metadata: failed HTTP request to URL "http://sigs.k8s.io/controller-runtime?go-get=1": Get https://sigs.k8s.io/controller-runtime?go-get=1: x509: certificate signed by unknown authority\n  \xe2\x9c\x97 unable to deduce repository and source type for "k8s.io/code-generator": unable to read metadata: unable to fetch raw metadata: failed HTTP request to URL "http://k8s.io/code-generator?go-get=1": Get https://k8s.io/code-generator?go-get=1: x509: certificate signed by unknown authority\n  \xe2\x9c\x97 unable to deduce repository and source type for "k8s.io/api": unable to read metadata: unable to fetch raw metadata: failed HTTP request to URL "http://k8s.io/api?go-get=1": Get https://k8s.io/api?go-get=1: x509: certificate signed by unknown authority\n
Run Code Online (Sandbox Code Playgroud)\n\n

如果我卷曲到https://k8s.io/api?go-get=1,它工作得很好,所以看起来 go 不信任该证书。

\n\n

有办法配置吗?

\n

wil*_*200 4

根据 go文档

在 UNIX 系统上,环境变量 SSL_CERT_FILE 和 SSL_CERT_DIR 可用于分别覆盖 SSL 证书文件和 SSL 证书文件目录的系统默认位置。

样本

SSL_CERT_FILE=/path/to/x509_encoded_cert_file dep ensure
SSL_CERT_DIR=/path/to/dir/ dep ensure
Run Code Online (Sandbox Code Playgroud)