-
Notifications
You must be signed in to change notification settings - Fork 3.9k
12326 :: DNS SAN matching does not handle wildcards in split patterns that Envoy does #12345
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
base: master
Are you sure you want to change the base?
Changes from all commits
919285c
6b0de5c
3f45fa6
f1265e7
35e38ce
1100be4
9e9875d
403faa8
cee6325
2e75fe0
e77a957
f1b3262
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,8 +21,10 @@ | |
import static io.grpc.xds.internal.security.CommonTlsContextTestsUtil.CA_PEM_FILE; | ||
import static io.grpc.xds.internal.security.CommonTlsContextTestsUtil.CLIENT_PEM_FILE; | ||
import static io.grpc.xds.internal.security.CommonTlsContextTestsUtil.CLIENT_SPIFFE_PEM_FILE; | ||
import static io.grpc.xds.internal.security.CommonTlsContextTestsUtil.SERVER_0_PEM_FILE; | ||
import static io.grpc.xds.internal.security.CommonTlsContextTestsUtil.SERVER_1_PEM_FILE; | ||
import static io.grpc.xds.internal.security.CommonTlsContextTestsUtil.SERVER_1_SPIFFE_PEM_FILE; | ||
import static org.junit.Assert.assertTrue; | ||
import static org.junit.Assert.fail; | ||
import static org.mockito.Mockito.CALLS_REAL_METHODS; | ||
import static org.mockito.Mockito.doReturn; | ||
|
@@ -691,6 +693,42 @@ public void unsupportedAltNameType() throws CertificateException, IOException { | |
} | ||
} | ||
|
||
private void runDnsWildcardTest( | ||
String sanPattern, String certFile, boolean ignoreCase, boolean expected) | ||
throws CertificateException, IOException { | ||
StringMatcher stringMatcher = | ||
StringMatcher.newBuilder() | ||
.setExact(sanPattern) | ||
.setIgnoreCase(ignoreCase) | ||
.build(); | ||
@SuppressWarnings("deprecation") | ||
CertificateValidationContext certContext = | ||
CertificateValidationContext.newBuilder() | ||
.addMatchSubjectAltNames(stringMatcher) | ||
.build(); | ||
trustManager = new XdsX509TrustManager(certContext, mockDelegate); | ||
X509Certificate[] certs = | ||
CertificateUtils.toX509Certificates(TlsTesting.loadCert(certFile)); | ||
try { | ||
trustManager.verifySubjectAltNameInChain(certs); | ||
assertTrue(expected); | ||
} catch (CertificateException certException) { | ||
assertThat(certException).hasMessageThat().isEqualTo("Peer certificate SAN check failed"); | ||
} | ||
} | ||
|
||
@Test | ||
public void testDnsWildcardPatterns() throws Exception { | ||
runDnsWildcardTest("*.test.google.fr", SERVER_1_PEM_FILE, false, true); | ||
runDnsWildcardTest("*.test.youtube.com", SERVER_1_PEM_FILE, false, true); | ||
runDnsWildcardTest("waterzooi.test.google.be", SERVER_1_PEM_FILE, false, true); | ||
runDnsWildcardTest("192.168.1.3", SERVER_1_PEM_FILE, false, true); | ||
runDnsWildcardTest("*.TEST.YOUTUBE.com", SERVER_1_PEM_FILE, true, true); | ||
runDnsWildcardTest("*.test.google.com.au", SERVER_0_PEM_FILE, false, true); | ||
runDnsWildcardTest("*.TEST.YOUTUBE.com", SERVER_1_PEM_FILE, false, false); | ||
runDnsWildcardTest("*waterzooi", SERVER_1_PEM_FILE, false, false); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This adds no value, we deny if xn-- is present in pattern[0], the failure here is due to other reasons, and is misleading. Change it to a negative test case with xn-- in pattern[0]. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kannanjgithub , I have not addressed this review comment yet because our current certificates do not include this pattern. I will address this in a future commit once we finalize the new patterns. |
||
|
||
private TestSslEngine buildTrustManagerAndGetSslEngine() | ||
throws CertificateException, IOException, CertStoreException { | ||
SSLParameters sslParams = buildTrustManagerAndGetSslParameters(); | ||
|
Uh oh!
There was an error while loading. Please reload this page.