use of okhttp3.internal.tls.CertificateChainCleaner in project okhttp by square.
the class CertificateChainCleanerTest method normalizeUnknownSelfSignedCertificate.
@Test
public void normalizeUnknownSelfSignedCertificate() throws Exception {
HeldCertificate root = new HeldCertificate.Builder().serialNumber("1").build();
CertificateChainCleaner cleaner = CertificateChainCleaner.get();
try {
cleaner.clean(list(root), "hostname");
fail();
} catch (SSLPeerUnverifiedException expected) {
}
}
use of okhttp3.internal.tls.CertificateChainCleaner in project okhttp by square.
the class CertificateChainCleanerTest method normalizeSingleSelfSignedCertificate.
@Test
public void normalizeSingleSelfSignedCertificate() throws Exception {
HeldCertificate root = new HeldCertificate.Builder().serialNumber("1").build();
CertificateChainCleaner cleaner = CertificateChainCleaner.get(root.certificate);
assertEquals(list(root), cleaner.clean(list(root), "hostname"));
}
use of okhttp3.internal.tls.CertificateChainCleaner in project okhttp by square.
the class CertificateChainCleanerTest method orderedChainOfCertificatesWithRoot.
@Test
public void orderedChainOfCertificatesWithRoot() 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), cleaner.clean(list(certB, certA, root), "hostname"));
}
use of okhttp3.internal.tls.CertificateChainCleaner in project okhttp by square.
the class CertificateChainCleanerTest method chainTooLong.
@Test
public void chainTooLong() throws Exception {
List<HeldCertificate> heldCertificates = chainOfLength(11);
List<Certificate> certificates = new ArrayList<>();
for (HeldCertificate heldCertificate : heldCertificates) {
certificates.add(heldCertificate.certificate);
}
X509Certificate root = heldCertificates.get(heldCertificates.size() - 1).certificate;
CertificateChainCleaner cleaner = CertificateChainCleaner.get(root);
try {
cleaner.clean(certificates, "hostname");
fail();
} catch (SSLPeerUnverifiedException expected) {
}
}
use of okhttp3.internal.tls.CertificateChainCleaner in project okhttp by square.
the class CertificateChainCleanerTest method chainGoesAllTheWayToSelfSignedRoot.
@Test
public void chainGoesAllTheWayToSelfSignedRoot() throws Exception {
HeldCertificate selfSigned = new HeldCertificate.Builder().serialNumber("1").build();
HeldCertificate trusted = new HeldCertificate.Builder().serialNumber("2").issuedBy(selfSigned).build();
HeldCertificate certA = new HeldCertificate.Builder().serialNumber("3").issuedBy(trusted).build();
HeldCertificate certB = new HeldCertificate.Builder().serialNumber("4").issuedBy(certA).build();
CertificateChainCleaner cleaner = CertificateChainCleaner.get(selfSigned.certificate, trusted.certificate);
assertEquals(list(certB, certA, trusted, selfSigned), cleaner.clean(list(certB, certA), "hostname"));
assertEquals(list(certB, certA, trusted, selfSigned), cleaner.clean(list(certB, certA, trusted), "hostname"));
assertEquals(list(certB, certA, trusted, selfSigned), cleaner.clean(list(certB, certA, trusted, selfSigned), "hostname"));
}
Aggregations