-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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
kubeadm: check all available CA certs against pinned certs #76500
Conversation
Hi @rojkov. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rojkov the PR seems good to me.
added a couple of suggested changes.
/approve
/ok-to-test
/priority backlog
/test pull-kubernetes-e2e-kind
} | ||
return errors.Errorf("public key %s not pinned", Hash(certificate)) | ||
return errors.Errorf("non of the public keys '%s' are pinned", strings.Join(hashes, ":")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
%s -> %q
if len(trailingData) != 0 { | ||
return nil, errors.New("trailing data after first PEM block") | ||
// parsePEMCerts decodes a PEM-formatted certificates into a slice of x509.Certificates | ||
func parsePEMCerts(certData []byte) ([]*x509.Certificate, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please modify this function to:
// parsePEMCerts decodes PEM-formatted certificates into a slice of x509.Certificates
func parsePEMCerts(certData []byte) ([]*x509.Certificate, error) {
var certificates []*x509.Certificate
var pemBlock *pem.Block
for {
pemBlock, certData = pem.Decode(certData)
if pemBlock == nil {
return nil, errors.New("invalid PEM data")
}
cert, err := x509.ParseCertificate(pemBlock.Bytes)
if err != nil {
return nil, errors.Wrap(err, "unable to parse certificate")
}
certificates = append(certificates, cert)
if len(certData) == 0 {
break
}
}
return certificates, nil
}
note the a PEM-
-> PEM
change in the function comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Fixed
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: neolit123, rojkov The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@kubernetes/sig-cluster-lifecycle-pr-reviews /lgtm |
} | ||
return errors.Errorf("public key %s not pinned", Hash(certificate)) | ||
return errors.Errorf("non of the public keys %q are pinned", strings.Join(hashes, ":")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
non -> none ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Corrected.
Currently kubeadm produces an error upon parsing multiple certificates stored in the cluster-info configmap. Yet it should check all available certificates in a scenario like CA key rotation. Check all available CA certs against pinned certificate hashes. Fixes kubernetes/kubeadm#1399
/lgtm |
/test pull-kubernetes-e2e-gce |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @rojkov
/lgtm
@neolit123 please unhold if you don't mind. Thanks. |
/hold cancel |
What type of PR is this?
/kind bug
What this PR does / why we need it:
Currently kubeadm produces an error upon parsing multiple certificates stored in the cluster-info configmap resulting in kubernetes/kubeadm#1399. Yet it's expected to check all available certificates in a scenario like CA key rotation. So, check all available CA certs against pinned certificate hashes.
Which issue(s) this PR fixes:
Fixes kubernetes/kubeadm#1399
Does this PR introduce a user-facing change?: