use of javax.net.ssl.SSLSocketFactory in project ecf by eclipse.
the class Activator method getSSLSocketFactory.
public synchronized SSLSocketFactory getSSLSocketFactory() {
if (sslSocketFactoryTracker == null) {
sslSocketFactoryTracker = new ServiceTracker(this.context, SSLSocketFactory.class.getName(), null);
sslSocketFactoryTracker.open();
}
return (SSLSocketFactory) sslSocketFactoryTracker.getService();
}
use of javax.net.ssl.SSLSocketFactory in project ecf by eclipse.
the class SSLClient method createSocket.
private Socket createSocket(String host, int port, int timeout) throws IOException {
SSLSocketFactory socketFactory = ProviderPlugin.getDefault().getSSLSocketFactory();
if (socketFactory == null)
// $NON-NLS-1$ //$NON-NLS-2$
throw new IOException("Cannot get SSLSocketFactory to create SSLSocket for host=" + host + ",port=" + port);
Socket s = socketFactory.createSocket();
s.connect(new InetSocketAddress(host, port), timeout);
return s;
}
use of javax.net.ssl.SSLSocketFactory in project http2client-benchmark by networknt.
the class OkHttpClientExample method getUnsafeOkHttpClient.
// http://stackoverflow.com/questions/25509296/trusting-all-certificates-with-okhttp
private static OkHttpClient getUnsafeOkHttpClient() {
try {
// Install the all-trusting trust manager
final SSLContext sslContext = SSLContext.getInstance("SSL");
sslContext.init(null, TRUST_ALL_CERTS, new java.security.SecureRandom());
// Create an ssl socket factory with our all-trusting manager
final SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory();
OkHttpClient okHttpClient = new OkHttpClient();
okHttpClient.newBuilder().sslSocketFactory(sslSocketFactory).hostnameVerifier((hostname, session) -> true);
return okHttpClient;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of javax.net.ssl.SSLSocketFactory in project cosmic by MissionCriticalCloud.
the class SecureSSLSocketFactory method createSocket.
@Override
public Socket createSocket(final InetAddress address, final int port, final InetAddress localAddress, final int localPort) throws IOException {
final SSLSocketFactory factory = this._sslContext.getSocketFactory();
final Socket socket = factory.createSocket(address, port, localAddress, localPort);
if (socket instanceof SSLSocket) {
((SSLSocket) socket).setEnabledProtocols(SSLUtils.getSupportedProtocols(((SSLSocket) socket).getEnabledProtocols()));
}
return socket;
}
use of javax.net.ssl.SSLSocketFactory in project cosmic by MissionCriticalCloud.
the class SecureSSLSocketFactory method createSocket.
@Override
public Socket createSocket(final String host, final int port) throws IOException, UnknownHostException {
final SSLSocketFactory factory = _sslContext.getSocketFactory();
final Socket socket = factory.createSocket(host, port);
if (socket instanceof SSLSocket) {
((SSLSocket) socket).setEnabledProtocols(SSLUtils.getSupportedProtocols(((SSLSocket) socket).getEnabledProtocols()));
}
return socket;
}
Aggregations