use of okhttp3.internal.tls.HeldCertificate 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.HeldCertificate 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.HeldCertificate in project okhttp by square.
the class CertificateChainCleanerTest method equalsFromCertificate.
@Test
public void equalsFromCertificate() throws Exception {
HeldCertificate rootA = new HeldCertificate.Builder().serialNumber("1").build();
HeldCertificate rootB = new HeldCertificate.Builder().serialNumber("2").build();
assertEquals(CertificateChainCleaner.get(rootA.certificate, rootB.certificate), CertificateChainCleaner.get(rootB.certificate, rootA.certificate));
}
use of okhttp3.internal.tls.HeldCertificate 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.HeldCertificate 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) {
}
}
Aggregations