mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Merge pull request #101977 from SataQiu/fix-kubeadm-allow-20210513
kubeadm: fix the bug that kubeadm only uses the first hash in caCertHashes to verify the root CA
This commit is contained in:
commit
2a106464d3
@ -59,7 +59,9 @@ func (s *Set) Allow(pubKeyHashes ...string) error {
|
|||||||
|
|
||||||
switch strings.ToLower(format) {
|
switch strings.ToLower(format) {
|
||||||
case "sha256":
|
case "sha256":
|
||||||
return s.allowSHA256(value)
|
if err := s.allowSHA256(value); err != nil {
|
||||||
|
return errors.Errorf("invalid hash %q, %v", pubKeyHash, err)
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return errors.Errorf("unknown hash format %q. Known format(s) are: %s", format, supportedFormats)
|
return errors.Errorf("unknown hash format %q. Known format(s) are: %s", format, supportedFormats)
|
||||||
}
|
}
|
||||||
|
@ -143,6 +143,17 @@ func TestSet(t *testing.T) {
|
|||||||
t.Error("expected the second test cert to be disallowed")
|
t.Error("expected the second test cert to be disallowed")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s = NewSet() // keep set empty
|
||||||
|
hashes := []string{
|
||||||
|
`sha256:0000000000000000000000000000000000000000000000000000000000000000`,
|
||||||
|
`sha256:0000000000000000000000000000000000000000000000000000000000000001`,
|
||||||
|
}
|
||||||
|
err = s.Allow(hashes...)
|
||||||
|
if err != nil || len(s.sha256Hashes) != 2 {
|
||||||
|
t.Error("expected allowing multiple hashes to succeed")
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestHash(t *testing.T) {
|
func TestHash(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user