use of org.apache.qpid.test.utils.tls.KeyCertificatePair in project qpid-broker-j by apache.
the class NonJavaTrustStoreTest method testCreationOfTrustStoreWithoutCRL.
@Test
public void testCreationOfTrustStoreWithoutCRL() throws Exception {
final KeyCertificatePair keyCertPair = TlsResourceBuilder.createSelfSigned(DN_FOO);
final Path certificateFile = TLS_RESOURCE.saveCertificateAsPem(keyCertPair.getCertificate());
Map<String, Object> attributes = new HashMap<>();
attributes.put(NonJavaTrustStore.NAME, NAME);
attributes.put(NonJavaTrustStore.CERTIFICATES_URL, certificateFile.toFile().getAbsolutePath());
attributes.put(NonJavaTrustStore.TYPE, NON_JAVA_TRUST_STORE);
attributes.put(NonJavaTrustStore.CERTIFICATE_REVOCATION_CHECK_ENABLED, false);
TrustStore<?> trustStore = createTestTrustStore(attributes);
TrustManager[] trustManagers = trustStore.getTrustManagers();
assertNotNull(trustManagers);
assertEquals("Unexpected number of trust managers", 1, trustManagers.length);
assertNotNull("Trust manager unexpected null", trustManagers[0]);
}
use of org.apache.qpid.test.utils.tls.KeyCertificatePair in project qpid-broker-j by apache.
the class NonJavaTrustStoreTest method testCreationOfTrustStoreFromValidCertificate_MissingCrlFile.
@Test
public void testCreationOfTrustStoreFromValidCertificate_MissingCrlFile() throws Exception {
final KeyCertificatePair keyCertPair = TlsResourceBuilder.createSelfSigned(DN_FOO);
final Path certificateFile = TLS_RESOURCE.saveCertificateAsPem(keyCertPair.getCertificate());
Map<String, Object> attributes = new HashMap<>();
attributes.put(NonJavaTrustStore.NAME, NAME);
attributes.put(NonJavaTrustStore.CERTIFICATES_URL, certificateFile.toFile().getAbsolutePath());
attributes.put(NonJavaTrustStore.TYPE, NON_JAVA_TRUST_STORE);
attributes.put(NonJavaTrustStore.CERTIFICATE_REVOCATION_CHECK_ENABLED, true);
attributes.put(NonJavaTrustStore.CERTIFICATE_REVOCATION_LIST_URL, NOT_A_CRL);
KeyStoreTestHelper.checkExceptionThrownDuringKeyStoreCreation(FACTORY, BROKER, TrustStore.class, attributes, String.format("Unable to load certificate revocation list '%s' for truststore '%s'", NOT_A_CRL, NAME));
}
use of org.apache.qpid.test.utils.tls.KeyCertificatePair in project qpid-broker-j by apache.
the class NonJavaTrustStoreTest method generateCertificateAndCrl.
private CertificateAndCrl<File> generateCertificateAndCrl() throws Exception {
final KeyCertificatePair caPair = TlsResourceBuilder.createKeyPairAndRootCA(DN_CA);
final KeyCertificatePair keyCertPair1 = TlsResourceBuilder.createKeyPairAndCertificate(DN_FOO, caPair);
final KeyCertificatePair keyCertPair2 = TlsResourceBuilder.createKeyPairAndCertificate(DN_BAR, caPair);
final Path clrFile = TLS_RESOURCE.createCrl(caPair, keyCertPair1.getCertificate(), keyCertPair2.getCertificate());
final Path caCertificateFile = TLS_RESOURCE.saveCertificateAsPem(caPair.getCertificate());
return new CertificateAndCrl<>(caCertificateFile.toFile(), clrFile.toFile(), caPair);
}
Aggregations