从远程主机获取接受自签名证书的方法

huangapple go评论73阅读模式
英文:

go get accept selfsigned certificate from distant host

问题

我想要能够使用一个友好的URL从我的Stash服务器上进行go get操作。我的Stash服务器只支持HTTPS。问题是,我在Stash上使用的SSL证书是自签名的,因此对我的服务器进行任何go get操作都会出现以下错误:

x509: certificate signed by unknown authority

有没有办法在go get中授权自签名证书?

英文:

I'd like to be able to go get from my Stash server with a nice URL. My stash server works only over HTTPS. The problem is that my SSL certificate I'm using with stash is self-signed and any go get to my server gets me the following error:

x509: certificate signed by unknown authority

Is there a way to authorize self-signed certificates from go get?

答案1

得分: 10

go get -insecure已被弃用。

从go 1.14开始,正确的方法是通过将GOINSECURE环境变量设置为一个逗号分隔的域名列表,用于忽略证书。

例如,在~/.zshrc中设置(如果使用zsh shell):

GOINSECURE=example.com

然后,您就可以像这样安装包:

go get example.com/some/pkg
英文:

go get -insecure has been deprecated.

As of go 1.14, the correct way to do this is by setting the GOINSECURE environment variable to a comma-separated list of domains from which you'd like to ignore the certs.

E.g. Setting in within ~/.zshrc (if zsh shell)

GOINSECURE=example.com

Then you will be able to install the packages like:

go get example.com/some/pkg

答案2

得分: 5

使用 go get -insecure https://xxxxx 命令。

根据 go get -h 的说明:

-insecure 标志允许从仓库获取和解析使用不安全协议(如HTTP)的自定义域名。请谨慎使用。

英文:

Use go get -insecure https://xxxxx.

From go get -h:

> The -insecure flag permits fetching from repositories and resolving
custom domains using insecure schemes such as HTTP. Use with caution.

huangapple
  • 本文由 发表于 2015年9月15日 08:18:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/32575775.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定