Docker go镜像 – 无法执行go get – x509: 由未知机构签署的证书

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

Docker go image - cannot go get - x509: certificate signed by unknown authority

问题

在Docker的Golang镜像中,我试图使用go install命令安装一个包,但是遇到了以下错误:

go install google.golang.org/protobuf/cmd/protoc-gen-go@1.27.0: google.golang.org/protobuf/cmd/protoc-gen-go@1.27.0: invalid version: Get "https://proxy.golang.org/google.golang.org/protobuf/cmd/protoc-gen-go/@v/1.27.0.info": x509: certificate signed by unknown authority

我尝试无法成功安装CA证书。

有什么想法是什么问题导致的?

英文:

inside docker golang image i am trying to go install a package and fail on this error:

go install google.golang.org/protobuf/cmd/protoc-gen-go@1.27.0: google.golang.org/protobuf/cmd/protoc-gen-go@1.27.0: invalid version: Get "https://proxy.golang.org/google.golang.org/protobuf/cmd/protoc-gen-go/@v/1.27.0.info": x509: certificate signed by unknown authority

i tried installing CA certificates unsuccessfully

any idea what could be the problem ?

答案1

得分: 11

好的,以下是翻译好的内容:

好的,问题出在我的安全客户端:Cisco AnyConnect "Umbrella"。

它表现得像一个中间人,并使用自己的证书重新签署请求。

为了让 Docker 中的 Go 客户端信任由 Cisco Umbrella 重新签署的流量,需要将 "Cisco Umbrella Root CA" 证书添加到 Docker 文件中:

Docker go镜像 – 无法执行go get – x509: 由未知机构签署的证书

点击 .cer URI,我们可以看到该证书。

现在在容器内部,我可以执行以下操作:

$ wget http://www.cisco.com/security/pki/certs/ciscoumbrellaroot.cer

然后将其从 .cer 转换为 .crt 文件:

$ openssl x509 -inform DER -in ciscoumbrellaroot.cer -out ciscoumbrellaroot.crt

然后将其复制到证书文件夹:

$ cp ciscoumbrellaroot.crt /usr/local/share/ca-certificates/ciscoumbrellaroot.crt

最后更新证书:

$ update-ca-certificates

输出如下:

Updating certificates in /etc/ssl/certs...
1 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.

完成!现在我们可以获取任何软件包:

$ go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.27.1
go: downloading google.golang.org/protobuf v1.27.1

这篇文章是关于 Cisco 安全客户端的,但可以适用于任何其他客户端。

英文:

Ok so the problem was my security client: Cisco AnyConnect "Umbrella".

it was acting like a man in the middle and re-sign the request with its own certificate.

in order for the in-docker go client to trust the traffic re-signed by the Cisco Umbrella, the "Cisco Umbrella Root CA" certificate was needed to be added to the docker file:

Docker go镜像 – 无法执行go get – x509: 由未知机构签署的证书

so clicking on the .cer URI we can see that certificate.

now inside my container i could:

$ wget http://www.cisco.com/security/pki/certs/ciscoumbrellaroot.cer

then convert it from .cer to a .crt file:

$ openssl x509 -inform DER -in ciscoumbrellaroot.cer -out ciscoumbrellaroot.crt

then copy it to the certificate folder:

$ cp ciscoumbrellaroot.crt /usr/local/share/ca-certificates/ciscoumbrellaroot.crt

and lastly update certificates:

$ update-ca-certificates

which outputs this:

Updating certificates in /etc/ssl/certs...
1 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.

done! now we can go get any package:

$ go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.27.1
go: downloading google.golang.org/protobuf v1.27.1

this was written about cisco security client but can be applied to any client out there

huangapple
  • 本文由 发表于 2021年7月11日 15:02:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/68333944.html
匿名

发表评论

匿名网友

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

确定