Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -215,23 +215,21 @@ public void handlerAdded(ChannelHandlerContext ctx) throws Exception {
this.sslContextProviderSupplier = sslContextProviderSupplier;
EnvoyServerProtoData.BaseTlsContext tlsContext = sslContextProviderSupplier.getTlsContext();
UpstreamTlsContext upstreamTlsContext = ((UpstreamTlsContext) tlsContext);
if (CertificateUtils.isXdsSniEnabled) {
String sniToUse = upstreamTlsContext.getAutoHostSni()
&& !Strings.isNullOrEmpty(endpointHostname)
? endpointHostname : upstreamTlsContext.getSni();
if (sniToUse.isEmpty()) {
if (CertificateUtils.useChannelAuthorityIfNoSniApplicable) {
sniToUse = grpcHandler.getAuthority();
}
autoSniSanValidationDoesNotApply = true;

String sniToUse = upstreamTlsContext.getAutoHostSni()
&& !Strings.isNullOrEmpty(endpointHostname)
? endpointHostname : upstreamTlsContext.getSni();
if (sniToUse.isEmpty()) {
if (CertificateUtils.useChannelAuthorityIfNoSniApplicable) {
sniToUse = grpcHandler.getAuthority();
} else {
autoSniSanValidationDoesNotApply = false;
sniToUse = "";
}
sni = sniToUse;
autoSniSanValidationDoesNotApply = true;
} else {
sni = grpcHandler.getAuthority();
autoSniSanValidationDoesNotApply = false;
}
sni = sniToUse;
}

@VisibleForTesting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
* Contains certificate utility method(s).
*/
public final class CertificateUtils {
public static boolean isXdsSniEnabled = GrpcUtil.getFlag("GRPC_EXPERIMENTAL_XDS_SNI", true);
public static boolean useChannelAuthorityIfNoSniApplicable
= GrpcUtil.getFlag("GRPC_USE_CHANNEL_AUTHORITY_IF_NO_SNI_APPLICABLE", false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ public void checkServerTrusted(X509Certificate[] chain, String authType)

private List<StringMatcher> getAutoSniSanMatchers(SSLParameters sslParams) {
List<StringMatcher> sniNamesToMatch = new ArrayList<>();
if (CertificateUtils.isXdsSniEnabled && autoSniSanValidation) {
if (autoSniSanValidation) {
List<SNIServerName> serverNames = sslParams.getServerNames();
if (serverNames != null) {
for (SNIServerName serverName : serverNames) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
import io.grpc.xds.internal.security.SslContextProviderSupplier;
import io.grpc.xds.internal.security.TlsContextManagerImpl;
import io.grpc.xds.internal.security.certprovider.FileWatcherCertificateProviderProvider;
import io.grpc.xds.internal.security.trust.CertificateUtils;
import io.netty.handler.ssl.NotSslRecordException;
import java.io.File;
import java.io.FileOutputStream;
Expand Down Expand Up @@ -317,7 +316,6 @@ public void tlsClientServer_noAutoSniValidation_failureToMatchSubjAltNames()
@Test
public void tlsClientServer_autoSniValidation_sniInUtc()
throws Exception {
CertificateUtils.isXdsSniEnabled = true;
Path trustStoreFilePath = getCacertFilePathForTestCa();
try {
setTrustStoreSystemProperties(trustStoreFilePath.toAbsolutePath().toString());
Expand All @@ -341,14 +339,12 @@ public void tlsClientServer_autoSniValidation_sniInUtc()
} finally {
Files.deleteIfExists(trustStoreFilePath);
clearTrustStoreSystemProperties();
CertificateUtils.isXdsSniEnabled = false;
}
}

@Test
public void tlsClientServer_autoSniValidation_sniFromHostname()
throws Exception {
CertificateUtils.isXdsSniEnabled = true;
Path trustStoreFilePath = getCacertFilePathForTestCa();
try {
setTrustStoreSystemProperties(trustStoreFilePath.toAbsolutePath().toString());
Expand All @@ -375,14 +371,12 @@ public void tlsClientServer_autoSniValidation_sniFromHostname()
} finally {
Files.deleteIfExists(trustStoreFilePath);
clearTrustStoreSystemProperties();
CertificateUtils.isXdsSniEnabled = false;
}
}

@Test
public void tlsClientServer_autoSniValidation_noSniApplicable_usesMatcherFromCmnVdnCtx()
throws Exception {
CertificateUtils.isXdsSniEnabled = true;
Path trustStoreFilePath = getCacertFilePathForTestCa();
try {
setTrustStoreSystemProperties(trustStoreFilePath.toAbsolutePath().toString());
Expand All @@ -406,7 +400,6 @@ public void tlsClientServer_autoSniValidation_noSniApplicable_usesMatcherFromCmn
} finally {
Files.deleteIfExists(trustStoreFilePath);
clearTrustStoreSystemProperties();
CertificateUtils.isXdsSniEnabled = false;
}
}

Expand Down
Loading