public class SSLContext extends Object
SSLEngines. This class is initialized with an optional set of key and trust managers and
 source of secure random bytes.
 
 Every implementation of the Java platform is required to support the following standard SSLContext
 protocol:
 
| Constructor and Description | 
|---|
| SSLContext() | 
| Modifier and Type | Method and Description | 
|---|---|
| static SSLContext | getDefault()Returns the default SSL context. | 
| static SSLContext | getInstance(String protocol)Returns a  SSLContextobject that implements the specified secure socket protocol. | 
| String | getProtocol()Returns the protocol name of this  SSLContextobject. | 
| SSLServerSocketFactory | getServerSocketFactory()Returns a  ServerSocketFactoryobject for this context. | 
| SSLSocketFactory | getSocketFactory()Returns a  SocketFactoryobject for this context. | 
| void | init(KeyManager[] km,
    TrustManager[] tm,
    SecureRandom random)Initializes this context. | 
public static SSLContext getDefault() throws NoSuchAlgorithmException
 The first call of this method triggers the call SSLContext.getInstance("Default"). If successful,
 that object is made the default SSL context and returned.
 
The default context is immediately usable and does not require initialization.
NoSuchAlgorithmException - if the SSLContext.getInstance() call failspublic static SSLContext getInstance(String protocol) throws NoSuchAlgorithmException
SSLContext object that implements the specified secure socket protocol.
 This method traverses the list of registered security Providers, starting with the most preferred Provider. A new SSLContext object encapsulating the SSLContextSpi implementation from the first Provider that supports the specified protocol is returned.
protocol - the standard name of the requested protocol. See the SSLContext section in the
             Java Cryptography
            Architecture Standard Algorithm Name Documentation for information about standard protocol names.SSLContext object.NoSuchAlgorithmException - if no Provider supports a SSLContextSpi implementation for the specified protocol.NullPointerException - if protocol is null.public final String getProtocol()
SSLContext object.
 
 This is the same name that was specified in one of the getInstance calls that created this
 SSLContext object.
SSLContext object.public final void init(@Nullable KeyManager[] km, @Nullable TrustManager[] tm, @Nullable SecureRandom random) throws KeyManagementException
Only the first instance of a particular key and/or trust manager implementation type in the array is used. (For example, only the first javax.net.ssl.X509KeyManager in the array will be used.)
km - the sources of authentication keys or nulltm - the sources of peer authentication trust decisions or nullrandom - the source of randomness for this generator or nullKeyManagementException - if this operation failspublic final SSLSocketFactory getSocketFactory()
SocketFactory object for this context.SocketFactory objectIllegalStateException - if the SSLContextImpl requires initialization and the init() has not been calledpublic final SSLServerSocketFactory getServerSocketFactory()
ServerSocketFactory object for this context.ServerSocketFactory objectIllegalStateException - if the SSLContextImpl requires initialization and the init() has not been called