-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/go: "go get gopkg.in/yaml.v2" will run into "x509: certificate signed by unknown authority" behind corporate proxy #18519
Comments
@davecheney you're right, the https cert will be replaced over company policy, so ... but anyway, I think this should be quite common, maybe. but the point is that there is no problem if I use
|
go get is not "just" a wrapper for git. one step is to invoke git but the first step is to fetch https://gopkg.in/yaml.v2.git to learn where that comes from. The certs that 'go get' is finding do not include the company MITM cert. On Linux the cert list is:
It sounds like whichever of those files is on your system does not include the company CA. If it did, go get would succeed at the https fetch. |
Actually, I see your $https_proxy above now. I don't know why go get would not be using that. |
@rsc, cmd/go/http.go doesn't set ProxyFromEnvironment: // impatientInsecureHTTPClient is used in -insecure mode,
// when we're connecting to https servers that might not be there
// or might be using self-signed certificates.
var impatientInsecureHTTPClient = &http.Client{
Timeout: 5 * time.Second,
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
},
},
} |
That is, we have different proxy behavior in --insecure mode. I'll send a CL. |
CL https://golang.org/cl/34818 mentions this issue. |
Be consistent on whether the http proxy environment variables are respected regardless of whether -insecure is used. Updates #18519 Change-Id: Ib157eaacfd342dd3bfcd03e64da18c98c609cae3 Reviewed-on: https://go-review.googlesource.com/34818 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
Thanks @bradfitz for your quick fix. While seems this fix only takes effect when I also have tested using the latest nightly build(?),
Does above log means |
Actually I have already imported related certs into /etc/ssl/certs/ca-certificates.crt before submitting this issue, and unfortunately without luck. Below is the steps what I do:
So seems |
@iamzhout, I don't think your nightly build was new enough. The bug fix was that |
@bradfitz I have built and tested latest golang code on master branch. As the fix says it will only take effect when using @rsc I just digged a little bit deeper to find out the root cause. It seems that the original gopkg site cert will be replaced by a dynamically generated cert which, instead of a constant one, will be different every single minute in validation start/end time fields, as shown in below picture. So it turns out that the problem is not in golang's X509 verification algorithm which will do byte comparison using bytes.Equal, but the cert itslef. I will try to contact IT guys in company to see if the troublesome dynamic cert policy could be changed, though most probably not. Thanks for your help. |
Okay, closing. |
Just to update that I missed to understand https cert quite well, and added leaf cert previously, not company cert which @rsc already pointed out . After I added the root company cert, problem got resolved perfectly. |
What version of Go are you using (
go version
)?both tested on:
go version go1.6.4 linux/amd64
go version go1.7.4 linux/amd64
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/zhout/paas/k8s_prjroot"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GO15VENDOREXPERIMENT="1"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"
What did you do?
export http_proxy=http://my-corporate-proxy:8080
export https_proxy=http://my-corporate-proxy:8080
go get -v -u gopkg.in/yaml.v2
What did you expect to see?
the repository should be got successfully.
What did you see instead?
while if I add
-insecure
option, it will be ok.But as to 3rd party tool like glide, there is no global option to add
-insecure
currently forglide update
orglide install
command, I think ifgo get
can resolve this X509 issue, it would be of much help!The text was updated successfully, but these errors were encountered: