Search in sources :

Example 26 with StringMatcher

use of io.envoyproxy.envoy.type.matcher.v3.StringMatcher in project grpc-java by grpc.

the class SdsX509TrustManagerTest method oneSanInPeerCerts_prefixIgnoreCase.

@Test
public void oneSanInPeerCerts_prefixIgnoreCase() throws CertificateException, IOException {
    StringMatcher stringMatcher = StringMatcher.newBuilder().setPrefix(// test.google.be
    "WaterZooi.").setIgnoreCase(true).build();
    CertificateValidationContext certContext = CertificateValidationContext.newBuilder().addMatchSubjectAltNames(stringMatcher).build();
    trustManager = new SdsX509TrustManager(certContext, mockDelegate);
    X509Certificate[] certs = CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
    trustManager.verifySubjectAltNameInChain(certs);
}
Also used : StringMatcher(io.envoyproxy.envoy.type.matcher.v3.StringMatcher) X509Certificate(java.security.cert.X509Certificate) CertificateValidationContext(io.envoyproxy.envoy.extensions.transport_sockets.tls.v3.CertificateValidationContext) Test(org.junit.Test)

Example 27 with StringMatcher

use of io.envoyproxy.envoy.type.matcher.v3.StringMatcher in project grpc-java by grpc.

the class SdsX509TrustManagerTest method oneSanInPeerCerts_suffixIgnoreCase.

@Test
public void oneSanInPeerCerts_suffixIgnoreCase() throws CertificateException, IOException {
    StringMatcher stringMatcher = StringMatcher.newBuilder().setSuffix(".GooGle.BE").setIgnoreCase(true).build();
    CertificateValidationContext certContext = CertificateValidationContext.newBuilder().addMatchSubjectAltNames(stringMatcher).build();
    trustManager = new SdsX509TrustManager(certContext, mockDelegate);
    X509Certificate[] certs = CertificateUtils.toX509Certificates(TestUtils.loadCert(SERVER_1_PEM_FILE));
    trustManager.verifySubjectAltNameInChain(certs);
}
Also used : StringMatcher(io.envoyproxy.envoy.type.matcher.v3.StringMatcher) X509Certificate(java.security.cert.X509Certificate) CertificateValidationContext(io.envoyproxy.envoy.extensions.transport_sockets.tls.v3.CertificateValidationContext) Test(org.junit.Test)

Aggregations

CertificateValidationContext (io.envoyproxy.envoy.extensions.transport_sockets.tls.v3.CertificateValidationContext)27 StringMatcher (io.envoyproxy.envoy.type.matcher.v3.StringMatcher)27 Test (org.junit.Test)27 X509Certificate (java.security.cert.X509Certificate)25 CertificateException (java.security.cert.CertificateException)12