Skip to content

Conversation

kannanjgithub
Copy link
Contributor

No description provided.

Copy link
Member

@ejona86 ejona86 left a comment

Choose a reason for hiding this comment

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

A bit tangential, but in updateSslContextWhenReady(), are we missing a check for isUsingSystemRootCerts in the isClientSideTls() block?

    } else if (isClientSideTls()) {
      if (savedTrustedRoots != null || savedSpiffeTrustMap != null) {

(If that needs fixing, it can be done in a separate PR).

@kannanjgithub
Copy link
Contributor Author

A bit tangential, but in updateSslContextWhenReady(), are we missing a check for isUsingSystemRootCerts in the isClientSideTls() block?

    } else if (isClientSideTls()) {
      if (savedTrustedRoots != null || savedSpiffeTrustMap != null) {

(If that needs fixing, it can be done in a separate PR).

I have added a comment explaining. I have also renamed isClientSideTls and isServerSideTls to more representative names. isClientSideTls always confuses me into thinking it is referring to client authetentication requiring presenting client certs but here it was just meant to mean "normal Tls and this code is running on client side". isServerSideTls also confuses me because any Tls always involves the server presenting its certificate and here it was just meant to mean "normal Tls and this code is running on server side". @ejona86

protected final boolean isClientSideTls() {
protected final boolean isNormalTlsAndClientSide() {
// We don't do (rootCertInstance != null || isUsingSystemRootCerts) here because of how this
// method is used. With the rootCertInstance being null when using system root certs, there
Copy link
Member

Choose a reason for hiding this comment

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

Is that true? Regular TLS on client-side doesn't match any cases in updateSslContextWhenReady(), and I don't see any other calls to updateSslContext().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's what I intended and wrote in this comment, because the root cert is from the system store and cannot be updated by the watcher mechanism which is what will invoke updateSslContextWhenReady. Only if it is Mtls, when the client cert needs changing, it shall happen via updateSslContextWhenReady. The system root cert shall never get updated. The first and only update for system root certs should happen right in SslContextProviderSupplier.updateSslContext by executing callback.updateSslContext on the callback's executor.
The file watcher based update should only update client certs if using Mtls.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was going to do the SslContext updating changes for system root certs in the SNI PR but I thought the better of it and have done those changes in this PR now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As discussed, removed the special handling for system root certs in SslContextProviderSupplier, and instead making the sslContext available in the constructor of the client SslContext provider.

@kannanjgithub kannanjgithub changed the title xds: When using System root certs ignore trusted root updates from the file watcher xds: SslContext updates handling when using system root certs Sep 10, 2025
…usted-root-updates

# Conflicts:
#	xds/src/main/java/io/grpc/xds/internal/security/certprovider/CertProviderClientSslContextProvider.java
if (rootCertInstance != null
&& rootCertInstance.isInitialized()
&& !rootCertInstance.getInstanceName().equals(certInstanceName)) {
if (createRootCertInstance && sharedCertInstance) {
Copy link
Member

Choose a reason for hiding this comment

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

This condition/block can be deleted while rootCertHandle isn't being used for the isMtls() and related functions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@kannanjgithub kannanjgithub merged commit 63fdaac into grpc:master Sep 25, 2025
21 of 23 checks passed
@kannanjgithub kannanjgithub deleted the systemrootcerts-ignore-trusted-root-updates branch September 25, 2025 06:42
AgraVator pushed a commit to AgraVator/grpc-java that referenced this pull request Sep 26, 2025
…2340)

Fixes the issues in SslContext not updated when using system root certs because it was using `CertProviderClientSslContextProvider` that relies on watcher updates from the certificate file watcher. This change creates a separate handler for system root certs and updates the SslContext on the `SslContextProvider` callback as soon as the provider is created.
AgraVator pushed a commit to AgraVator/grpc-java that referenced this pull request Sep 26, 2025
…2340)

Fixes the issues in SslContext not updated when using system root certs because it was using `CertProviderClientSslContextProvider` that relies on watcher updates from the certificate file watcher. This change creates a separate handler for system root certs and updates the SslContext on the `SslContextProvider` callback as soon as the provider is created.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants