x509 error with certificate-authority-data: pin mergo dependency against kubernetes/client-go compatible version#3497
Conversation
This issue was noticed when istioctl returned "x509: certificate signed by unknown authority" in combination with a cluster in ~/.kube/config that specifies its certificate using certificate-authority-data. The merging in https://github.com/kubernetes/client-go/blob/b6a34c5a002893138005771f76480e7166da9310/tools/clientcmd/loader.go#L225-L227 results in `CertificateAuthorityData` containing the base64-decoded certificate twice, which results in the x509 error.
|
Hi @steffengy. Thanks for your PR. I'm waiting for a istio member to verify that this patch is reasonable to test. If it is, they should reply with I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: costinm The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
|
/test all [submit-queue is verifying that this PR is safe to merge] |
|
Automatic merge from submit-queue. |
|
the changes from this pr btw are: curious which line in that diff is the bug we are fixing ? |
|
@ldemailly In hindsight that's quite logical that it's that commit, but bisecting works too: package main
import (
"bytes"
"fmt"
"github.com/imdario/mergo"
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
)
func main() {
mapConfig := clientcmdapi.NewConfig()
cluster := clientcmdapi.NewCluster()
cluster.CertificateAuthorityData = []byte("testdata")
mapConfig.Clusters["test"] = cluster
nonMapConfig := clientcmdapi.NewConfig()
cluster = clientcmdapi.NewCluster()
cluster.CertificateAuthorityData = []byte("testdata")
nonMapConfig.Clusters["test"] = cluster
config := clientcmdapi.NewConfig()
mergo.Merge(config, mapConfig)
mergo.Merge(config, nonMapConfig)
fmt.Println(string(config.Clusters["test"].CertificateAuthorityData))
authority := config.Clusters["test"].CertificateAuthorityData
if bytes.Compare(authority, []byte("testdata")) != 0 {
panic("CertificateAuthorityData does not match")
}
} |
|
ic, thanks a lot, I would report the bug in client go, as mergo quite clearly document their intent? |
|
@ldemailly A comment at https://github.com/kubernetes/client-go/blob/b6a34c5a002893138005771f76480e7166da9310/tools/clientcmd/loader.go#L225-L227 |
|
mergo should probably have bumped major or at least minor on that change |
|
not sure what you mean by ignore by go dep btw |
|
@ldemailly |
* (Rfc) adding vendor as submodule Receiving objects: 100% (4145/4145), 8.26 MiB | 930.00 KiB/s, done. Note: adding pruning instruction to Gopkg.toml makes vendor be 54Mb instead of 407Mb * Example of rebase, matching master's change to .lock * Adding submodule target to init + example of update flow Ran dep ensure --update istio.io/fortio To pick up 0.6.8 from 0.6.7 Checked in vendor/ submodule first and now this commit * No need to cache vendor with this setup * No cache needed/used * Added make targets like fortio's for submodule + Fun of touching dozens of circleci builds... * Removed unnecessary .lock copy * Merge and dip ensure * Fix for #3483 * Update from master matches master ed69c3a and #3497
This issue was noticed when istioctl returned
"x509: certificate signed by unknown authority"
in combination with a cluster in ~/.kube/config that
specifies its cluster certificate using certificate-authority-data.
The merging in
https://github.com/kubernetes/client-go/blob/b6a34c5a002893138005771f76480e7166da9310/tools/clientcmd/loader.go#L225-L227
results in
CertificateAuthorityDatacontaining the base64-decodedcertificate twice, which results in the x509 error.
Potentially related to https://github.com/kubernetes/client-go/blob/7cd1d3291b7d9b1e2d54d4b69eb65995eaf8888e/tools/clientcmd/client_config.go#L160-L162.
Not sure if that's the right way to fix that issue, I'd also appreciate
some pointers on the best approach to add tests for this.