英文:
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 文件中:
点击 .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:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论