use of javax.net.ssl.ExtendedSSLSession in project neo4j by neo4j.
the class CertConfiguredSecureSocketConnection method getSeenOcspResponses.
public Set<BasicOCSPResp> getSeenOcspResponses() throws IOException, OCSPException {
Set<BasicOCSPResp> ocspResponses = new HashSet<>();
List<byte[]> binaryStatusResponses = ((ExtendedSSLSession) ((SSLSocket) getSocket()).getSession()).getStatusResponses();
for (byte[] bResp : binaryStatusResponses) {
if (bResp.length > 0) {
OCSPResp ocspResp = new OCSPResp(bResp);
ocspResponses.add((BasicOCSPResp) ocspResp.getResponseObject());
}
}
return ocspResponses;
}
use of javax.net.ssl.ExtendedSSLSession in project netty by netty.
the class SniClientJava8TestUtil method assertSSLSession.
private static void assertSSLSession(boolean clientSide, SSLSession session, SNIServerName name) {
assertNotNull(session);
if (session instanceof ExtendedSSLSession) {
ExtendedSSLSession extendedSSLSession = (ExtendedSSLSession) session;
List<SNIServerName> names = extendedSSLSession.getRequestedServerNames();
assertEquals(1, names.size());
assertEquals(name, names.get(0));
assertTrue(extendedSSLSession.getLocalSupportedSignatureAlgorithms().length > 0);
if (clientSide) {
assertEquals(0, extendedSSLSession.getPeerSupportedSignatureAlgorithms().length);
} else {
assertTrue(extendedSSLSession.getPeerSupportedSignatureAlgorithms().length >= 0);
}
}
}
use of javax.net.ssl.ExtendedSSLSession in project j2objc by google.
the class SSLSocketTest method test_SSLSocket_SNIHostName.
public void test_SSLSocket_SNIHostName() throws Exception {
TestSSLContext c = TestSSLContext.create();
final SSLSocket client = (SSLSocket) c.clientContext.getSocketFactory().createSocket();
SSLParameters clientParams = client.getSSLParameters();
clientParams.setServerNames(Collections.singletonList((SNIServerName) new SNIHostName("www.example.com")));
client.setSSLParameters(clientParams);
SSLParameters serverParams = c.serverSocket.getSSLParameters();
serverParams.setSNIMatchers(Collections.singletonList(SNIHostName.createSNIMatcher("www\\.example\\.com")));
c.serverSocket.setSSLParameters(serverParams);
client.connect(new InetSocketAddress(c.host, c.port));
final SSLSocket server = (SSLSocket) c.serverSocket.accept();
ExecutorService executor = Executors.newSingleThreadExecutor();
Future<Void> future = executor.submit(new Callable<Void>() {
@Override
public Void call() throws Exception {
client.startHandshake();
return null;
}
});
executor.shutdown();
server.startHandshake();
SSLSession serverSession = server.getSession();
assertTrue(serverSession instanceof ExtendedSSLSession);
ExtendedSSLSession extendedServerSession = (ExtendedSSLSession) serverSession;
List<SNIServerName> requestedNames = extendedServerSession.getRequestedServerNames();
assertNotNull(requestedNames);
assertEquals(1, requestedNames.size());
SNIServerName serverName = requestedNames.get(0);
assertEquals(StandardConstants.SNI_HOST_NAME, serverName.getType());
assertTrue(serverName instanceof SNIHostName);
SNIHostName serverHostName = (SNIHostName) serverName;
assertEquals("www.example.com", serverHostName.getAsciiName());
}
use of javax.net.ssl.ExtendedSSLSession in project hono by eclipse.
the class SniExtensionHelperTest method testGetRequestedHostNamesExtractsAllHostNames.
/**
* Verifies that all host names are extracted from a TLS session.
*/
@Test
public void testGetRequestedHostNamesExtractsAllHostNames() {
final ExtendedSSLSession session = mock(ExtendedSSLSession.class);
when(session.getRequestedServerNames()).thenReturn(List.of(new SNIHostName("tenant.hono.eclipse.org"), new UndefinedServerName(new byte[] { 0x01, 0x02, 0x03 }), new SNIHostName("bumlux.eclipse.org")));
final List<String> hostNames = SniExtensionHelper.getHostNames(session);
assertThat(hostNames).containsExactly("tenant.hono.eclipse.org", "bumlux.eclipse.org");
}
Aggregations