Name
SSLContext
Synopsis
This class
is a factory for socket and server socket factories. Although most
applications do not need to use this class directly, it is the
central class of the javax.net.ssl
package. Most
applications use the default SSLSocketFactory
and
SSLServerSocketFactory
objects returned by the
static getDefault( )
methods of those classes.
Applications that want to perform SSL networking using a security
provider other than the default provider, or that want to customize
key management or trust management for the SSL connection should use
custom socket factories created from a custom
SSLContext
. In Java 5.0, this class also includes
createSSLEngine( )
factory methods for creating
SSLEngine
objects.
Create an SSLContext
by passing the name of the
desired secure socket protocol and, optionally, the desired provider
to getInstance( )
. The default
“SunJSSE” provider supports
protocol strings “SSL”,
“SSLv2”,
“SSLv3”,
“TLS”, and
“TLSv1”. Once you have created an
SSLContext
object, call its init(
)
method to supply the KeyManager
,
TrustManager
, and SecureRandom
objects it requires. If any of the init( )
arguments is null
, a default value will be used.
Finally, obtain a SSLSocketFactory
and
SSLServerSocketFactory
by calling
getSocketFactory(
)
and getServerSocketFactory(
)
.
public class SSLContext { // Protected Constructors protected SSLContext(SSLContextSpi contextSpi, java.security.Provider provider, String protocol); // Public Class Methods public static SSLContext ...
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.