use of org.apache.qpid.server.transport.TransportException in project qpid-broker-j by apache.
the class SSLUtil method verifyHostname.
public static void verifyHostname(final String hostnameExpected, final X509Certificate cert) {
try {
SortedSet<String> names = getNamesFromCert(cert);
if (names.isEmpty()) {
throw new TransportException("SSL hostname verification failed. Certificate for did not contain CN or DNS subjectAlt");
}
boolean match = verifyHostname(hostnameExpected, names);
if (!match) {
throw new TransportException("SSL hostname verification failed." + " Expected : " + hostnameExpected + " Found in cert : " + names);
}
} catch (InvalidNameException e) {
Principal p = cert.getSubjectDN();
String dn = p.getName();
throw new TransportException("SSL hostname verification failed. Could not parse name " + dn, e);
} catch (CertificateParsingException e) {
throw new TransportException("SSL hostname verification failed. Could not parse certificate: " + e.getMessage(), e);
}
}
use of org.apache.qpid.server.transport.TransportException in project qpid-broker-j by apache.
the class SSLUtilTest method doNameMatchingTest.
private void doNameMatchingTest(byte[] keystoreBytes, List<String> validAddresses, List<String> invalidAddresses) throws Exception {
KeyStore keyStore = KeyStore.getInstance("JKS");
keyStore.load(new ByteArrayInputStream(keystoreBytes), "password".toCharArray());
KeyStore trustStore = KeyStore.getInstance("JKS");
trustStore.load(new ByteArrayInputStream(TRUSTSTORE), "password".toCharArray());
for (String validAddress : validAddresses) {
try {
SSLUtil.verifyHostname(getSSLEngineAfterHandshake(keyStore, trustStore, validAddress, 5672), validAddress);
} catch (TransportException e) {
fail("The address " + validAddress + " should validate but does not");
}
}
for (String invalidAddress : invalidAddresses) {
try {
SSLUtil.verifyHostname(getSSLEngineAfterHandshake(keyStore, trustStore, invalidAddress, 5672), invalidAddress);
fail("The address " + invalidAddress + " should not validate but it does");
} catch (TransportException e) {
// pass
}
}
}
use of org.apache.qpid.server.transport.TransportException in project qpid-broker-j by apache.
the class AMQPConnection_0_8Impl method closed.
@Override
public void closed() {
try {
try {
if (!_orderlyClose.get()) {
completeAndCloseAllChannels();
}
} finally {
performDeleteTasks();
final NamedAddressSpace virtualHost = getAddressSpace();
if (virtualHost != null) {
virtualHost.deregisterConnection(this);
}
}
} catch (ConnectionScopedRuntimeException | TransportException e) {
LOGGER.error("Could not close protocol engine", e);
} finally {
markTransportClosed();
}
}
Aggregations