Name

SSLServerSocket

Synopsis

This class is an SSL-enabled subclass of java.net.ServerSocket that is used to listen for and accept connections from clients and to create SSLSocket objects for communicating with those clients. Create an SSLServerSocket and bind it to a local port by calling one of the inherited getServerSocket( ) methods of an SSLServerSocketFactory. Once a SSLServerSocket is created, use it as you would a regular ServerSocket: call the inherited accept( ) method to wait for and accept a connection from a client, returning a Socket object. With SSLServerSocket, the Socket returned by accept( ) can always be cast to an instance of SSLSocket.

SSLServerSocket defines methods for setting the enabled protocols and cipher suites, and for querying the full set of supported protocols and suites. See SSLSocket , which has methods with the same names, for details. If your server desires or requires authentication by its clients, call setWantClientAuth( ) or setNeedClientAuth( ). These methods cause the SSLSocket objects returned by accept( ) to be configured to request or require client authentication.

In typical SSL networking scenarios, the client requires the server to provide authentication information. When you create an SSLServerSocket using the default SSLServerSocketFactory, the authentication information required is an X.509 public key certificate and the corresponding private key. The default SSLServerSocketFactory uses an X509KeyManager to obtain this information. ...

Get Java in a Nutshell, 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.