use of okhttp3.internal.tls.HeldCertificate in project okhttp by square.
the class CertificateChainCleanerTest method orderedChainOfCertificatesWithoutRoot.
@Test
public void orderedChainOfCertificatesWithoutRoot() 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();
CertificateChainCleaner cleaner = CertificateChainCleaner.get(root.certificate);
assertEquals(list(certB, certA, root), // Root is added!
cleaner.clean(list(certB, certA), "hostname"));
}
use of okhttp3.internal.tls.HeldCertificate in project okhttp by square.
the class CertificateChainCleanerTest method unorderedChainOfCertificatesWithRoot.
@Test
public void unorderedChainOfCertificatesWithRoot() 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, root, certB), "hostname"));
}
use of okhttp3.internal.tls.HeldCertificate in project okhttp by square.
the class CertificateChainCleanerTest method trustedRootNotSelfSigned.
@Test
public void trustedRootNotSelfSigned() throws Exception {
HeldCertificate unknownSigner = new HeldCertificate.Builder().serialNumber("1").build();
HeldCertificate trusted = new HeldCertificate.Builder().issuedBy(unknownSigner).serialNumber("2").build();
HeldCertificate intermediateCa = new HeldCertificate.Builder().issuedBy(trusted).serialNumber("3").build();
HeldCertificate certificate = new HeldCertificate.Builder().issuedBy(intermediateCa).serialNumber("4").build();
CertificateChainCleaner cleaner = CertificateChainCleaner.get(trusted.certificate);
assertEquals(list(certificate, intermediateCa, trusted), cleaner.clean(list(certificate, intermediateCa), "hostname"));
assertEquals(list(certificate, intermediateCa, trusted), cleaner.clean(list(certificate, intermediateCa, trusted), "hostname"));
}
use of okhttp3.internal.tls.HeldCertificate 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"));
}
Aggregations