Search in sources :

Example 11 with CertificateChainCleaner

use of okhttp3.internal.tls.CertificateChainCleaner in project okhttp by square.

the class CertificateChainCleanerTest method unorderedChainOfCertificatesWithoutRoot.

@Test
public void unorderedChainOfCertificatesWithoutRoot() throws Exception {
    HeldCertificate root = new HeldCertificate.Builder().serialNumber("1").build();
    HeldCertificate certA = new HeldCertificate.Builder().serialNumber("2").issuedBy(root).build();
    HeldCertificate certB = new HeldCertificate.Builder().serialNumber("3").issuedBy(certA).build();
    HeldCertificate certC = new HeldCertificate.Builder().serialNumber("4").issuedBy(certB).build();
    CertificateChainCleaner cleaner = CertificateChainCleaner.get(root.certificate);
    assertEquals(list(certC, certB, certA, root), cleaner.clean(list(certC, certA, certB), "hostname"));
}
Also used : HeldCertificate(okhttp3.internal.tls.HeldCertificate) CertificateChainCleaner(okhttp3.internal.tls.CertificateChainCleaner) Test(org.junit.Test)

Aggregations

CertificateChainCleaner (okhttp3.internal.tls.CertificateChainCleaner)11 HeldCertificate (okhttp3.internal.tls.HeldCertificate)11 Test (org.junit.Test)11 Certificate (java.security.cert.Certificate)2 X509Certificate (java.security.cert.X509Certificate)2 ArrayList (java.util.ArrayList)2 SSLPeerUnverifiedException (javax.net.ssl.SSLPeerUnverifiedException)2