Code example for SSLSocketFactory

Methods: createSocket

0
                return delegate.isSecure(sock);
            } 
            @Override public Socket createSocket(Socket socket, String host, int port,
                    boolean autoClose) throws IOException {
                injectHostname(socket, host);
                return delegate.createSocket(socket, host, port, autoClose);
            } 
            private void injectHostname(Socket socket, String host) {
                try { 
                    Field field = InetAddress.class.getDeclaredField("hostName");
                    field.setAccessible(true);
                    field.set(socket.getInetAddress(), host);
                } catch (Exception ignored) {
                } 
            } 
        }; 
        client.getConnectionManager().getSchemeRegistry()
                .register(new Scheme("https", socketFactory, 443));
    } 
     
    public static void setApplicationContext(Context applicationContext) {