Commit bb153a8
authored
xds: Trust Manager fix for when SAN validation against SNI sent doesn't apply (#12775)
Fixes a bug in propagation of `autoSniSanValidationDoesNotApply` (from
PR #12422). It added an argument `autoSniSanValidationDoesNotApply` to
`SslContextProviderSupplier.updateSslContext` that sets it on the
`DynamicSslContextProvider` but because `UpstreamTlsContext` equals
wasn't implemented, it was getting replaced by a new instance and the
flag getting lost. This issue was identified when fixing an incorrect
merge caused error in `CertProviderClientSslContextProvider` that
recreated the trust manager without consideration to
`autoSniSanValidationDoesNotApply`. It ought to have caused failure in
the test
`XdsSecurityClientServerTest.tlsClientServer_autoSniValidation_noSniApplicable_usesMatcherFromCmnVdnCtx`
but it wasn't, because even though `autoSniSanValidationDoesNotApply`
was false due to not getting the propagated true value, SAN matcher
fallback was still happening because there was no server SNI sent.
With the new changes, in addition to fixing the equals method, by moving
the decision about autoSniSanValidationDoesNotApply to
TlsContextManagerImpl.findOrCreateClientSslContextProvider I have
eliminated the need to have a deferred setting of this decision via
DynamicSslContextProvider.setAutoSniSanValidationDoesNotApply called
from SslContextProviderSupplier.updateSslContext.
Summary of Changes:
1. Enhanced `UpstreamTlsContext` (EnvoyServerProtoData.java):
* Modified Caching Behavior: Implemented full equals() and hashCode()
overrides for `UpstreamTlsContext`. Previously, it relied on the base
class which only compared the commonTlsContext, causing different SNI or
auto-validation settings to incorrectly share the same cache entry.
* Normalization: Updated constructors to normalize the sni field to an
empty string ("") if null. This prevents equality mismatches between
context objects created from different sources (e.g., test helpers vs.
Envoy protos).
2. Centralized Validation Logic in `TlsContextManagerImpl`
* API Update: Modified `findOrCreateClientSslContextProvider` to accept
the `autoSniSanValidationDoesNotApply` flag.
* Effective Key Generation: If the flag is true, the manager now creates
a specialized UpstreamTlsContext for the cache lookup where
`autoSniSanValidation` is forced to false.
This ensures the cache key reflects the effective validation behavior,
allowing subchannels with different hostname/IP types to correctly share
or separate their `SslContextProvider` instances.
3. Propagated Flag through `SslContextProviderSupplier`:
* Updated the supplier to pass the validation flag from the
`ClientSecurityHandler` down to the manager and provider.
* Simplified the lifecycle by removing the need for a separate setter on
the provider.
4. Refined `DynamicSslContextProvider` and
`CertProviderClientSslContextProvider`:
* Removed the redundant `setAutoSniSanValidationDoesNotApply` method and
state.
* The provider now retrieves the final validation state directly from
its immutable `UpstreamTlsContext` during context computation.
5. Strengthened Integration Tests (XdsSecurityClientServerTest.java)
* Modified the test
`tlsClientServer_autoSniValidation_noSniApplicable_usesMatcherFromCmnVdnCtx`
to enable `CertificateUtils.useChannelAuthorityIfNoSniApplicable.`
* This forces the client to use the channel's authority as a non-empty
SNI that mismatches the server certificate. This ensures the test
rigorously asserts that SNI validation is truly disabled when it "does
not apply" (e.g., when no specific SNI was requested by the user).
6. Updated Test Suite & API Alignment
* SecurityProtocolNegotiatorsTest: Updated test cases to pass true for
the validation flag. This was required because the new strict cache key
equality exposed that the test was previously using a state that didn't
match the ClientSecurityHandler it was testing.1 parent 01c0a90 commit bb153a8
6 files changed
Lines changed: 67 additions & 46 deletions
File tree
- xds/src
- main/java/io/grpc/xds
- internal/security
- certprovider
- test/java/io/grpc/xds
- internal/security
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
82 | 89 | | |
83 | | - | |
84 | | - | |
85 | | - | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
86 | 93 | | |
87 | 94 | | |
88 | 95 | | |
| |||
122 | 129 | | |
123 | 130 | | |
124 | 131 | | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
125 | 152 | | |
126 | 153 | | |
127 | 154 | | |
| |||
Lines changed: 0 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
48 | 47 | | |
49 | 48 | | |
50 | 49 | | |
| |||
60 | 59 | | |
61 | 60 | | |
62 | 61 | | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | 62 | | |
68 | 63 | | |
69 | 64 | | |
| |||
Lines changed: 16 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
| 63 | + | |
67 | 64 | | |
68 | 65 | | |
69 | 66 | | |
70 | | - | |
| 67 | + | |
71 | 68 | | |
72 | 69 | | |
73 | 70 | | |
| |||
102 | 99 | | |
103 | 100 | | |
104 | 101 | | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
110 | 116 | | |
111 | 117 | | |
112 | 118 | | |
| |||
Lines changed: 11 additions & 25 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
| 61 | + | |
| 62 | + | |
62 | 63 | | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
69 | 68 | | |
70 | | - | |
71 | | - | |
| 69 | + | |
72 | 70 | | |
73 | 71 | | |
74 | | - | |
75 | | - | |
| 72 | + | |
76 | 73 | | |
77 | 74 | | |
78 | 75 | | |
79 | 76 | | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
94 | 80 | | |
95 | 81 | | |
96 | 82 | | |
| |||
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| 80 | + | |
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
| |||
378 | 379 | | |
379 | 380 | | |
380 | 381 | | |
| 382 | + | |
| 383 | + | |
381 | 384 | | |
| 385 | + | |
| 386 | + | |
382 | 387 | | |
383 | 388 | | |
384 | 389 | | |
| |||
398 | 403 | | |
399 | 404 | | |
400 | 405 | | |
| 406 | + | |
| 407 | + | |
401 | 408 | | |
402 | 409 | | |
403 | 410 | | |
| |||
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
212 | | - | |
| 212 | + | |
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
| |||
356 | 356 | | |
357 | 357 | | |
358 | 358 | | |
359 | | - | |
| 359 | + | |
360 | 360 | | |
361 | 361 | | |
362 | 362 | | |
| |||
493 | 493 | | |
494 | 494 | | |
495 | 495 | | |
496 | | - | |
| 496 | + | |
497 | 497 | | |
498 | 498 | | |
499 | 499 | | |
| |||
0 commit comments