Skip to content
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

Max workload cert lifetime should not apply to istiod's server cert #28640

Merged
merged 2 commits into from
Nov 6, 2020

Conversation

myidpt
Copy link

@myidpt myidpt commented Nov 6, 2020

When using self-signed Istiod CA, Istiod server needs a long-lived cert signed by Istiod CA itself (we make its lifetime equals the CA cert lifetime). Because the Istiod CA checks the requested lifetime should be smaller than the max workload cert lifetime, we extended the max workload cert to be equal to the CA cert lifetime. This actually makes the max workload cert lifetime effectiveless.

This PR fixes this by not conducting the max workload cert lifetime check for the Istiod server's certificate issuance (called via GenKeyCertNoLifetimeChecking). The max workload cert lifetime is still effective (by default 90 days) against normal workload cert issuance.

[ ] Configuration Infrastructure
[ ] Docs
[ ] Installation
[ ] Networking
[ ] Performance and Scalability
[ ] Policies and Telemetry
[ X ] Security
[ ] Test and Release
[ ] User Experience
[ ] Developer Infrastructure

Pull Request Attributes

Please check any characteristics that apply to this pull request.

[ ] Does not have any changes that may affect Istio users.

@myidpt myidpt requested review from howardjohn and shankgan November 6, 2020 04:58
@myidpt myidpt requested review from a team as code owners November 6, 2020 04:58
@google-cla google-cla bot added the cla: yes Set by the Google CLA bot to indicate the author of a PR has signed the Google CLA. label Nov 6, 2020
@istio-testing istio-testing added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 6, 2020
Copy link
Member

@howardjohn howardjohn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but should there be some unit tests of this?

// returns the certificate chain and the private key.
func (ca *IstioCA) GenKeyCert(hostnames []string, certTTL time.Duration) ([]byte, []byte, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be a good idea to pass in the checkLifetime parameter to this function as well? This function appears to be called by a couple of test_functions that use it to generate a key-cert pair for workload certs as well. Perhaps we just don't need lifetime checking in those cases?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that works. I can do that.

@@ -80,7 +80,7 @@ func TestAgent(t *testing.T) {
defer tearDown()

// TODO: when authz is implemented, verify labels are checked.
cert, key, err := bs.CA.GenKeyCert([]string{spiffe.Identity{"cluster.local", "test", "sa"}.String()}, 1*time.Hour)
cert, key, err := bs.CA.GenKeyCertNoLifetimeCheck([]string{spiffe.Identity{"cluster.local", "test", "sa"}.String()}, 1*time.Hour)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we are generating certs for a workload. Should be okay to not check the lifetime in this case though...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I didn't notice this test is generating for a workload... I can write a function GenKeyCert() for this test, to make this 100% accurate.

@myidpt
Copy link
Author

myidpt commented Nov 6, 2020

@howardjohn I'll add a unit test for it.

@myidpt myidpt added the release-notes-none Indicates a PR that does not require release notes. label Nov 6, 2020
@myidpt
Copy link
Author

myidpt commented Nov 6, 2020

/test release-notes_istio

@myidpt
Copy link
Author

myidpt commented Nov 6, 2020

/test integ-multicluster-k8s-tests_istio

@myidpt
Copy link
Author

myidpt commented Nov 6, 2020

/retest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/security cla: yes Set by the Google CLA bot to indicate the author of a PR has signed the Google CLA. release-notes-none Indicates a PR that does not require release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants