|
16 | 16 |
|
17 | 17 | package io.grpc.xds.internal.security; |
18 | 18 |
|
19 | | -import static com.google.common.base.Preconditions.checkNotNull; |
20 | | - |
21 | 19 | import com.google.common.annotations.VisibleForTesting; |
22 | 20 | import com.google.common.base.MoreObjects; |
23 | | -import io.grpc.netty.GrpcSslContexts; |
24 | 21 | import io.grpc.xds.EnvoyServerProtoData.BaseTlsContext; |
25 | 22 | import io.grpc.xds.EnvoyServerProtoData.DownstreamTlsContext; |
26 | 23 | import io.grpc.xds.EnvoyServerProtoData.UpstreamTlsContext; |
|
29 | 26 |
|
30 | 27 | import java.util.HashSet; |
31 | 28 | import java.util.Objects; |
32 | | -import javax.net.ssl.SSLException; |
33 | 29 | import java.util.Set; |
34 | 30 |
|
| 31 | +import static com.google.common.base.Preconditions.checkNotNull; |
| 32 | + |
35 | 33 | /** |
36 | 34 | * Enables Client or server side to initialize this object with the received {@link BaseTlsContext} |
37 | 35 | * and communicate it to the consumer i.e. {@link SecurityProtocolNegotiators} |
@@ -67,39 +65,22 @@ public synchronized void updateSslContext(final SslContextProvider.Callback call |
67 | 65 | } |
68 | 66 | } |
69 | 67 | // we want to increment the ref-count so call findOrCreate again... |
70 | | - final SslContextProvider toRelease = getSslContextProvider(); |
| 68 | + final SslContextProvider toRelease = getSslContextProvider(sni); |
71 | 69 | toRelease.addCallback( |
72 | 70 | new SslContextProvider.Callback(callback.getExecutor()) { |
73 | | - final SslContextProvider toRelease = getSslContextProvider(sni); |
74 | | - // When using system root certs on client side, SslContext updates via CertificateProvider is |
75 | | - // only required if Mtls is also enabled, i.e. tlsContext has a cert provider instance. |
76 | | - if (tlsContext instanceof UpstreamTlsContext |
77 | | - && !CommonTlsContextUtil.hasCertProviderInstance(tlsContext.getCommonTlsContext()) |
78 | | - && CommonTlsContextUtil.isUsingSystemRootCerts(tlsContext.getCommonTlsContext())) { |
79 | | - callback.getExecutor().execute(() -> { |
80 | | - try { |
81 | | - callback.updateSslContext(GrpcSslContexts.forClient().build()); |
| 71 | + |
| 72 | + @Override |
| 73 | + public void updateSslContext(SslContext sslContext) { |
| 74 | + callback.updateSslContext(sslContext); |
| 75 | + releaseSslContextProvider(toRelease, sni); |
| 76 | + } |
| 77 | + |
| 78 | + @Override |
| 79 | + public void onException(Throwable throwable) { |
| 80 | + callback.onException(throwable); |
82 | 81 | releaseSslContextProvider(toRelease, sni); |
83 | | - } catch (SSLException e) { |
84 | | - callback.onException(e); |
85 | 82 | } |
86 | 83 | }); |
87 | | - } else { |
88 | | - toRelease.addCallback( |
89 | | - new SslContextProvider.Callback(callback.getExecutor()) { |
90 | | - |
91 | | - @Override |
92 | | - public void updateSslContext(SslContext sslContext) { |
93 | | - callback.updateSslContext(sslContext); |
94 | | - releaseSslContextProvider(toRelease, sni); |
95 | | - } |
96 | | - |
97 | | - @Override |
98 | | - public void onException(Throwable throwable) { |
99 | | - callback.onException(throwable); |
100 | | - releaseSslContextProvider(toRelease, sni); |
101 | | - } |
102 | | - }); |
103 | 84 | } catch (final Throwable throwable) { |
104 | 85 | callback.getExecutor().execute(new Runnable() { |
105 | 86 | @Override |
|
0 commit comments