# JSSE client socket example

John Sullivan (john@webscope3d.com)
Tue, 10 Aug 1999 15:12:50 -0700

- Messages sorted by: [ date ][ thread ][ subject ][ author ]
- Next message: John Sullivan: "Setting server certificate"
- Previous message: Jeff Nisewanger: "RE: JSSE"

    Date: Tue, 10 Aug 1999 15:12:50 -0700

    From: John Sullivan <john@webscope3d.com>

    To: java-security@Sun.COM

    Subject: JSSE client socket example

I have implemented a client socket using the new JSSE
It code looks something like

Use JsseSocket.getSocket ( host , port );

/** This class contains all the interface code for making a JSSE
* SSL client socket */

// ssl provider imports
import java.security.Security;
import com.sun.net.ssl.internal.ssl.Provider;
import java.net.Socket;
import javax.net.ssl.SSLSocketFactory;
import javax.net.SocketFactory;

public class JsseSocket {

static {
Security.addProvider ( new Provider () );
System.setProperty ( "java.protocol.handler.pkgs" ,
"com.sun.net.ssl.internal.www.protocol" );
}

public static Socket getSocket ( String host , int port ) throws
Exception {
SocketFactory socketFactory = SSLSocketFactory.getDefault
();
Socket socket = socketFactory.createSocket (host,
port);
return socket;
}
}

- Next message: John Sullivan: "Setting server certificate"
- Previous message: Jeff Nisewanger: "RE: JSSE"