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

add ecdsa certificate support at gateways #3466

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

ramaraochavali
Copy link
Contributor

For istio/istio#36181.

Also needed for Gateway API

@ramaraochavali ramaraochavali added the release-notes-none Indicates a PR that does not require release notes. label Mar 12, 2025
@ramaraochavali ramaraochavali requested a review from a team as a code owner March 12, 2025 11:26
@istio-testing istio-testing added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Mar 12, 2025
Signed-off-by: Rama Chavali <[email protected]>
@@ -471,6 +471,31 @@ message ServerTLSSettings {
// or credentialName can be specified.
string credential_name = 10;

// Same as CredentialName but for multiple certificates. Mainly used for specifying
// RSA and ECDSA certificates for the same server.
repeated string credential_names = 14;
Copy link
Member

Choose a reason for hiding this comment

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

Are we going to support an arbitrary number or only 2? If a limit, can we add CEL validation?

Do we expect the certificates to be identical except in algorithm? Or could they, for instance, be multiple distinct SANs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only 2. I will add CEL validation.

Do we expect the certificates to be identical except in algorithm? Or could they, for instance, be multiple distinct SANs

Yes. I was n't expecting/not thinking of use case for different SANs

Copy link
Member

@howardjohn howardjohn Mar 12, 2025

Choose a reason for hiding this comment

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

Can we also make sure you set either credential_name or credential_names but not both (and same for tls_certificate(s) I think?)

Yes. I was n't expecting/not thinking of use case for different SANs

OK, I think we cannot actually validate it but we can just comment that is the intended usage maybe?

What happens in envoy if they don't match

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What happens in envoy if they don't match

Whatever certificate Envoy picked for TLS termination, it will validate the configured SAN's with available SAN's on that certificate.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added validations. PTAL. one thing I could not add is
only one of cred*, (server_certificate, private_key),tls_certificates can be specified. Do you know if it is possible?

@istio-testing istio-testing added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Mar 14, 2025
Signed-off-by: Rama Chavali <[email protected]>
@ramaraochavali
Copy link
Contributor Author

@howardjohn can you PTAL when you get chance?

@@ -381,6 +381,11 @@ message Port {
}

message ServerTLSSettings {
// +kubebuilder:validation:XValidation:message="credential_names cannot have more than two credentials",rule="default(self.credential_names, []).size() <= 2"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// +kubebuilder:validation:XValidation:message="credential_names cannot have more than two credentials",rule="default(self.credential_names, []).size() <= 2"
// +kubebuilder:validation:XValidation:message="credential_names cannot have more than two credentials",rule="default(self.credentialName, []).size() <= 2"

The CEL works on the CRD naming, not the proto, which is camelCase. Might be worth adding that note into GUIDELINES.md.

We could add a test under tests/testdata/ to catch this

Copy link
Member

Choose a reason for hiding this comment

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

Also this would need to be over message ServerTLSSettings to work, not under it.

But even better, this could be only the specific field itself (ex over tls_certificates).

or even better, we do not need CEL for this; can use kubebuilder:validation:items:MaxItems. We should also probably put MinItems=1

Copy link
Member

Choose a reason for hiding this comment

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

So to clarify:

  • The two oneof checks need to be on ServerTLSSettings, since it needs access to the fields. It needs to change to camel case
  • The two checks of size should move to the field level and use MinItems/MaxItems

Comment on lines 386 to 387
// +kubebuilder:validation:XValidation:message="only one of credential_names or tls_certificates can be set",rule="oneof(self.tls_certificates, self.credential_names)"
// +kubebuilder:validation:XValidation:message="only one of credential_name or credential_names can be set",rule="oneof(self.credential_name, self.credential_names)"
Copy link
Member

Choose a reason for hiding this comment

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

Do we intentionally allow tls_certificate + credential_names?

Copy link
Contributor

Choose a reason for hiding this comment

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

My vote would be no

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we intentionally allow tls_certificate + credential_names?

No. only one of them. That was the oneof I added. Any issue with that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nvm. I did not add that combination. Fixed now

Comment on lines 386 to 387
// +kubebuilder:validation:XValidation:message="only one of credential_names or tls_certificates can be set",rule="oneof(self.tls_certificates, self.credential_names)"
// +kubebuilder:validation:XValidation:message="only one of credential_name or credential_names can be set",rule="oneof(self.credential_name, self.credential_names)"
Copy link
Contributor

Choose a reason for hiding this comment

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

My vote would be no

// A list of alternate names to verify the subject identity in the
// certificate presented by the client.
// Requires TLS mode to be set to `MUTUAL`.
// When multiple certificates are provided via `credential_names` or `tls_certificates`,
Copy link
Contributor

Choose a reason for hiding this comment

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

What's doing the validating? If the validation fails, what errors?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the existing SAN validation and you get certificate verify failed message.

Signed-off-by: Rama Chavali <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-notes-none Indicates a PR that does not require release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants