Closed
Description
Please answer these questions before submitting your issue. Thanks!
What did you do?
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
$ go get -d k8s.io/kubernetes
package k8s.io/kubernetes: unrecognized import path "k8s.io/kubernetes" (https fetch: Get https://k8s.io/kubernetes?go-get=1: x509: certificate signed by unknown authority)
What did you expect to see?
Packages can be pulled down and installed directly
What did you see instead?
The x509 certificate error prevents everything
System details
go version go1.10 darwin/amd64
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/phye/Library/Caches/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Volumes/gitws/go"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.10/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.10/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/ch/0fcsjfy14kd6jgpzwky0ggvm0000gn/T/go-build042818790=/tmp/go-build -gno-record-gcc-switches -fno-common"
GOROOT/bin/go version: go version go1.10 darwin/amd64
GOROOT/bin/go tool compile -V: compile version go1.10
uname -v: Darwin Kernel Version 17.4.0: Sun Dec 17 09:19:54 PST 2017; root:xnu-4570.41.2~1/RELEASE_X86_64
ProductName: Mac OS X
ProductVersion: 10.13.3
BuildVersion: 17D102
lldb --version: lldb-900.0.64
Swift-4.0
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
adamdecaf commentedon Feb 27, 2018
@phye Have you modified your keychain certificate trust? k8s.io looks to use Let's Encrypt which should be trusted on your mac.
phye commentedon Feb 28, 2018
I don't think I've ever modified my keychain certificate trust. Anyway, since I'm not familiar with encrypt/decrypt, if you can provide me hint to check that, I can provide more info follow your instructions.
On the other hand, I've tried
curl -kv https://k8s.io:443
on my mac and it works just fine, onlygo get
failed with x509 certificate sign error.adamdecaf commentedon Feb 28, 2018
curl -k
skips certificate verification. On a mac curl might use a different certificate store (openssl) than what Go uses depending on how it's installed.Could you paste the full output of
curl -kv https://k8s.io:443
and verify "DST Root CA X3" is in your keychain and trusted?k8s.io is currently serving a Let's Encrypt certificate: https://letsencrypt.org/certificates/
That requires either DST Root CA X3 or ISRG Root X1 trusted on your mac.
On my Mac
DST Root CA X3
exists and is trusted. Ago get -v -d k8s.io/kubernetes
works for me and I'm on macOS10.13.3
. (Same as you)[-]Various go get failed with "x509: certificate signed by unknown authority"[/-][+]crypto/tls: go get failed on Mac with "x509: certificate signed by unknown authority"[/+]phye commentedon Mar 1, 2018
I'm sorry, I meant
curl -v https://k8s.io:443
works for me on my mac, typo tocurl -kv
...Here's output for
curl -v https://k8s.io:443
:Here's
go get -v -d k8s.io/kubernetes
:Strange enough, I only recalled that I've once imported some certificate for our customer, but never deleted any.
I further checked DST Root CA and ISRG Root X1, and they're all there in my Keychain Access. Somehow go simply could not find them or ignore them?
Regarding how go is installed, I simply install it via homebrew:
brew install go
.adamdecaf commentedon Mar 1, 2018
That's odd. I was able to reproduce the error if I marked
DST Root CA X3
as 'Never Trust' in keychain.The cgo code which collects certs doesn't offer much for debug logging. Are you willing to add some and see what's outputted?
I'm going to file a CL, which you could use, to add some debug logging for this going forward.
gopherbot commentedon Mar 1, 2018
Change https://golang.org/cl/97801 mentions this issue:
crypto/x509: print more debug info for cgo darwin path
phye commentedon Mar 1, 2018
Sure, let me follow the CL to provide more info. Thanks for your patient help!
phye commentedon Mar 1, 2018
I was trying to apply your patch, but apparently the diff you provided does not match my
root_cgo_darwin.go
(attached).I was using go 1.10, can you send a matching one?
Also, do you know how to apply your diff directly via CLIs? I've never applied golang CL before, hence the silly question.
root_cgo_darwin.go.txt
adamdecaf commentedon Mar 1, 2018
@phye You can Download the patch and apply it like so. Afterwords, you'll need to
make.bash
insrc
and then you should have a go binary. (In../bin/go
fromsrc/
)I forgot to include some sample code you can use to print the system certs.
Thanks for helping debug this!
phye commentedon Mar 2, 2018
I'm sorry @adamdecaf, as I stated earlier, your diff does not match what I have locally. Here'e the apply output:
Can you send me a new patch?
adamdecaf commentedon Mar 2, 2018
@phye What git hash are you on? I'm basing the change off the Go1.10 tag.
https://github.com/golang/go/blob/go1.10/src/crypto/x509/root_cgo_darwin.go
Looking at your file again (#24147 (comment)) you might be on an older version. Around go1.5
This version looks very similar to the one you posted. https://github.com/golang/go/blob/go1.5/src/crypto/x509/root_cgo_darwin.go
phye commentedon Mar 3, 2018
You're right @adamdecaf !
Firstly, I've made some silly mistake that I came to know only after reading your reply... There're actually two mixing go environments in my mac: 1) A very old 1.5 go installed manually by me via official packages for OS X, 2) A relatively fresh go 1.10 environment that I installed (later) via
brew install go
. When pasting the root_cgo_darwin.go I was uploading the wrong file, also I was applying the patch in the wrong 1.5 folder...Having realized the silly mistake above, I tried to completely remove the 'brew install' 1.10 go version, the very old 1.5 go and tried to reinstall go 1.10 via the official OSX golang 1.10 packages. But unfortunately, I still cannot run
go get -d k8s.io/kubernetes
.So, here's the output after applying your patch:
phye commentedon Mar 3, 2018
@adamdecaf I seems to find something odd, the
DST Root CA X3,O=Digital Signature Trust Co
is marked as trusted in my Keychain Access, not the same asDST Root CA X4
, which is simplythis cert is valid
.And in the output above, you can find the this certificate is listed in
untrusted
.phye commentedon Mar 3, 2018
@adamdecaf, somehow I found two
DST Root CA X3,O=Digital Signature Trust Co
in my keychain access, one is insystem
keychains, another is insystem roots
. After I removed the one insystem
keychains, the other one insystem roots
becomesvalid
automatically! Unbelievable!Anyway, I can
go get -d k8s.io/kubernetes
now!Thanks so much for your help!
adamdecaf commentedon Mar 3, 2018
@phye Sure thing! Glad we didn't find a bug.
The
System.keychain
is useful to modify trust of certificates across all users on a Mac.@bradfitz (or someone) could you close this out?
https://golang.org/cl/97801 helped debug the problem here and would be nice to get merged.