use of javax.net.ssl.SSLSession in project robovm by robovm.
the class SSLSessionTest method test_invalidate.
/**
* javax.net.ssl.SSLSession#invalidate()
* javax.net.ssl.SSLSession#isValid()
*/
public void test_invalidate() {
SSLSession s = clientSession;
assertTrue(s.isValid());
s.invalidate();
assertFalse(s.isValid());
}
use of javax.net.ssl.SSLSession in project robovm by robovm.
the class HandshakeCompletedEventTest method test_getSession.
/**
* @throws IOException
* javax.net.ssl.HandshakeCompletedEvent#getSession()
*/
public final void test_getSession() throws IOException {
mySSLSession session = new mySSLSession("localhost", 1080, null);
SSLSocket socket = (SSLSocket) SSLSocketFactory.getDefault().createSocket();
HandshakeCompletedEvent event = new HandshakeCompletedEvent(socket, session);
SSLSession ss = event.getSession();
assertNotNull(ss);
assertEquals(session, ss);
}
use of javax.net.ssl.SSLSession in project android_frameworks_base by crdroidandroid.
the class RootTrustManager method checkServerTrusted.
@Override
public void checkServerTrusted(X509Certificate[] certs, String authType, SSLEngine engine) throws CertificateException {
SSLSession session = engine.getHandshakeSession();
if (session == null) {
throw new CertificateException("Not in handshake; no session available");
}
String host = session.getPeerHost();
NetworkSecurityConfig config = mConfig.getConfigForHostname(host);
config.getTrustManager().checkServerTrusted(certs, authType, engine);
}
use of javax.net.ssl.SSLSession in project Gargoyle by callakrsos.
the class HostNameVertifierInitializer method initialize.
@Override
public void initialize() throws Exception {
LOGGER.debug(getClass().getName() + " initialize.");
HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
@Override
public boolean verify(String arg0, SSLSession arg1) {
LOGGER.debug(arg0);
return true;
}
});
}
use of javax.net.ssl.SSLSession in project jdk8u_jdk by JetBrains.
the class X509TrustManagerImpl method checkTrusted.
private void checkTrusted(X509Certificate[] chain, String authType, Socket socket, boolean isClient) throws CertificateException {
Validator v = checkTrustedInit(chain, authType, isClient);
AlgorithmConstraints constraints = null;
if ((socket != null) && socket.isConnected() && (socket instanceof SSLSocket)) {
SSLSocket sslSocket = (SSLSocket) socket;
SSLSession session = sslSocket.getHandshakeSession();
if (session == null) {
throw new CertificateException("No handshake session");
}
// check endpoint identity
String identityAlg = sslSocket.getSSLParameters().getEndpointIdentificationAlgorithm();
if (identityAlg != null && identityAlg.length() != 0) {
checkIdentity(session, chain[0], identityAlg, isClient, getRequestedServerNames(socket));
}
// create the algorithm constraints
ProtocolVersion protocolVersion = ProtocolVersion.valueOf(session.getProtocol());
if (protocolVersion.v >= ProtocolVersion.TLS12.v) {
if (session instanceof ExtendedSSLSession) {
ExtendedSSLSession extSession = (ExtendedSSLSession) session;
String[] localSupportedSignAlgs = extSession.getLocalSupportedSignatureAlgorithms();
constraints = new SSLAlgorithmConstraints(sslSocket, localSupportedSignAlgs, false);
} else {
constraints = new SSLAlgorithmConstraints(sslSocket, false);
}
} else {
constraints = new SSLAlgorithmConstraints(sslSocket, false);
}
}
X509Certificate[] trustedChain = null;
if (isClient) {
trustedChain = validate(v, chain, constraints, null);
} else {
trustedChain = validate(v, chain, constraints, authType);
}
if (debug != null && Debug.isOn("trustmanager")) {
System.out.println("Found trusted certificate:");
System.out.println(trustedChain[trustedChain.length - 1]);
}
}
Aggregations