Code example for SSLSocketFactory

Methods: createSocket

    public SSLSocket getSecureSocket(SSLSocketFactory sslSocketFactory, HostnameVerifier hostnameVerifier) throws IOException {
        if(!usingSecureSocket) {
            String hostName = config.getHostName();
            int port = config.getHostPort();
            // create the wrapper over connected socket 
            sslSocket = (SSLSocket) sslSocketFactory.createSocket(socket,
                    hostName, port, true);
            if (!hostnameVerifier.verify(hostName, sslSocket.getSession())) {
                throw new IOException(Messages.getString("luni.02", hostName)); //$NON-NLS-1$
            usingSecureSocket = true;
        return sslSocket;
    Socket getSocket() {
        return socket;
Stop searching for code, let great code find you!  Add Codota to your java IDE