@Test
void v3Cert() throws Exception
{

    CertifiedPublicKey interCaCert = factory.decode(v3InterCaCert);
    CertifiedPublicKey certificate = factory.decode(v3Cert);
    assertTrue(certificate.isSignedBy(interCaCert.getPublicKeyParameters()),
        "End certificate should be verified by CA.");
    assertThat(certificate, instanceOf(X509CertifiedPublicKey.class));
    X509CertifiedPublicKey cert = (X509CertifiedPublicKey) certificate;
    assertThat(cert.getVersionNumber(), equalTo(3));
    assertTrue(cert.getExtensions().isCritical(KeyUsage.OID), "KeyUsage extension should be critical.");
    assertThat(cert.getExtensions().getKeyUsage(), equalTo(EnumSet.of(KeyUsage.digitalSignature,
        KeyUsage.dataEncipherment)));
    assertFalse(cert.getExtensions().isCritical(ExtendedKeyUsages.OID),
        "ExtendedKeyUsage extension should be non critical.");
    assertThat(cert.getExtensions().getExtendedKeyUsage().getAll().toArray(new String[0]), equalTo(
        new String[]{ ExtendedKeyUsages.EMAIL_PROTECTION }));
    assertTrue(cert.getExtensions().getExtendedKeyUsage().hasUsage(ExtendedKeyUsages.EMAIL_PROTECTION),
        "Email data protection extended usage should be set.");
    assertThat(cert.getAuthorityKeyIdentifier(),
        equalTo(((X509CertifiedPublicKey) interCaCert).getSubjectKeyIdentifier()));
    assertThat(cert.isRootCA(), equalTo(false));
}