/** * @see SecureProtocolSocketFactory#createSocket(java.lang.String,int) */ public Socket createSocket(String host, int port) throws IOException, UnknownHostException { return SSLSocketFactory.getDefault().createSocket( host, port ); }
private SSLSocketFactory getDefaultFactory() { return (SSLSocketFactory) SSLSocketFactory.getDefault(); }
public DefaultJavaSSLFactory(Properties info) { _factory = (SSLSocketFactory) SSLSocketFactory.getDefault(); } }
/** * @see SecureProtocolSocketFactory#createSocket(java.net.Socket,java.lang.String,int,boolean) */ public Socket createSocket( Socket socket, String host, int port, boolean autoClose) throws IOException, UnknownHostException { return ((SSLSocketFactory) SSLSocketFactory.getDefault()).createSocket( socket, host, port, autoClose ); }
/** * @see SecureProtocolSocketFactory#createSocket(java.lang.String,int) */ public Socket createSocket(String host, int port) throws IOException, UnknownHostException { return SSLSocketFactory.getDefault().createSocket( host, port ); }
public ProxyThread(Socket socket, OnRequestListener listener, ArrayList<Proxy.ProxyFilter> filters, String hostRedirection, int portRedirection) throws IOException{ super("ProxyThread"); mSocket = socket; mWriter = null; mReader = mSocket.getInputStream(); mRequestListener = listener; mFilters = filters; mHostRedirect = hostRedirection; mPortRedirect = portRedirection; mSocketFactory = SSLSocketFactory.getDefault(); }
public StompConnection(String dest, String userid, String password, boolean reconnect, boolean ssl) {; server_destinations.add(dest); this.userid = userid; this.password = password; this.reconnect = reconnect; if (ssl) socket_factory = SSLSocketFactory.getDefault(); else socket_factory = SocketFactory.getDefault(); this.sslParameters = null; }
/** * @see SecureProtocolSocketFactory#createSocket(java.lang.String,int,java.net.InetAddress,int) */ public Socket createSocket( String host, int port, InetAddress clientHost, int clientPort) throws IOException, UnknownHostException { return SSLSocketFactory.getDefault().createSocket( host, port, clientHost, clientPort ); }
/** * @see SecureProtocolSocketFactory#createSocket(java.net.Socket,java.lang.String,int,boolean) */ public Socket createSocket( Socket socket, String host, int port, boolean autoClose) throws IOException, UnknownHostException { return ((SSLSocketFactory) SSLSocketFactory.getDefault()).createSocket( socket, host, port, autoClose ); }
SSLSocketFactory sslsocketfactory = (SSLSocketFactory) SSLSocketFactory.getDefault(); URL url = new URL("https://gridserver:3049/cgi-bin/ls.py"); HttpsURLConnection conn = (HttpsURLConnection)url.openConnection(); conn.setSSLSocketFactory(sslsocketfactory); InputStream inputstream = conn.getInputStream(); InputStreamReader inputstreamreader = new InputStreamReader(inputstream); BufferedReader bufferedreader = new BufferedReader(inputstreamreader); String string = null; while ((string = bufferedreader.readLine()) != null) { System.out.println("Received " + string); }
public GoServer() { this(new SystemEnvironment(), (SSLSocketFactory) SSLSocketFactory.getDefault()); }
/** * Returns default SSL socket factory allowing setting trust managers. */ protected SSLSocketFactory getDefaultSSLSocketFactory(final boolean trustAllCertificates) throws IOException { if (trustAllCertificates) { try { SSLContext sc = SSLContext.getInstance(sslProtocol); sc.init(null, TrustManagers.TRUST_ALL_CERTS, new java.security.SecureRandom()); return sc.getSocketFactory(); } catch (NoSuchAlgorithmException | KeyManagementException e) { throw new IOException(e); } } else { return (SSLSocketFactory) SSLSocketFactory.getDefault(); } }
public SocketFactory selectSocketFactory(boolean secure) { if (secure) { if (mSSLContext != null) { return mSSLContext.getSocketFactory(); } if (mSSLSocketFactory != null) { return mSSLSocketFactory; } return SSLSocketFactory.getDefault(); } if (mSocketFactory != null) { return mSocketFactory; } return SocketFactory.getDefault(); } }
@Override public Socket accept() throws IOException { Socket socket = super.accept(); SSLSocketFactory sslSocketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault(); SSLSocket sslSocket = (SSLSocket) sslSocketFactory.createSocket(socket, socket.getInetAddress().getHostName(), socket.getPort(), true); sslSocket.setUseClientMode(false); sslSocket.setNeedClientAuth(false); ArrayList<String> secureProtocols = new ArrayList<>(); for (String p : sslSocket.getEnabledProtocols()) { if (!p.contains("SSLv3")) { secureProtocols.add(p); } } sslSocket.setEnabledProtocols(secureProtocols.toArray(new String[secureProtocols.size()])); return sslSocket; } };
/** * @deprecated */ public static void sendWithSSlSocket(String urlLink) { SSLSocketFactory sslsocketfactory = (SSLSocketFactory) SSLSocketFactory.getDefault(); URL url = null; try { url = new URL(urlLink); HttpsURLConnection conn = (HttpsURLConnection) url.openConnection(); conn.setSSLSocketFactory(sslsocketfactory); InputStream inputstream = conn.getInputStream(); InputStreamReader inputstreamreader = new InputStreamReader(inputstream); BufferedReader bufferedreader = new BufferedReader(inputstreamreader); String string = null; while ((string = bufferedreader.readLine()) != null) { System.out.println("Received " + string); } } catch (Exception e) { e.printStackTrace(); Logs.e(e, ""); } }
private Socket createSocket(URI target) throws Exception { if (isSsl(target)) { return SSLSocketFactory.getDefault().createSocket(); } return new Socket(); }
/** * Create a secure client socket that is connected to the given address and * port. * * @param address the address to connect to * @param port the port * @return the socket */ public static Socket createSocket(InetAddress address, int port) throws IOException { Socket socket = null; setKeystore(); SSLSocketFactory f = (SSLSocketFactory) SSLSocketFactory.getDefault(); SSLSocket secureSocket = (SSLSocket) f.createSocket(); secureSocket.connect(new InetSocketAddress(address, port), SysProperties.SOCKET_CONNECT_TIMEOUT); secureSocket.setEnabledProtocols( disableSSL(secureSocket.getEnabledProtocols())); if (SysProperties.ENABLE_ANONYMOUS_TLS) { String[] list = enableAnonymous( secureSocket.getEnabledCipherSuites(), secureSocket.getSupportedCipherSuites()); secureSocket.setEnabledCipherSuites(list); } socket = secureSocket; return socket; }
/** * Creates a new SSL SocketFactory. The given factory will use user-provided * key and trust managers (if the user provided them). * * @return Newly created (Ssl)SocketFactory. * @throws IOException */ @Override protected SocketFactory createSocketFactory() throws IOException { if( SslContext.getCurrentSslContext()!=null ) { SslContext ctx = SslContext.getCurrentSslContext(); try { return ctx.getSSLContext().getSocketFactory(); } catch (Exception e) { throw IOExceptionSupport.create(e); } } else { return SSLSocketFactory.getDefault(); } }
/** * Creates a new SSL SocketFactory. The given factory will use user-provided * key and trust managers (if the user provided them). * * @return Newly created (Ssl)SocketFactory. * @throws IOException */ @Override protected SocketFactory createSocketFactory() throws IOException { if (SslContext.getCurrentSslContext() != null) { SslContext ctx = SslContext.getCurrentSslContext(); try { return ctx.getSSLContext().getSocketFactory(); } catch (Exception e) { throw IOExceptionSupport.create(e); } } else { return SSLSocketFactory.getDefault(); } }
@Test public void support_tls_versions_of_java8() { underTest = HttpConnector.newBuilder().url(serverUrl).build(); assertTlsAndClearTextSpecifications(underTest); assertThat(underTest.okHttpClient().sslSocketFactory()).isInstanceOf(SSLSocketFactory.getDefault().getClass()); }