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 protocols:
TLSv1.2TLSv1.3| Modifier and Type | Field and Description |
|---|---|
| private final SSLContextSpi | |
| private static volatile SSLContext | |
| private final String | |
| private final Provider | |
| private static final VarHandle |
| Access | Constructor and Description |
|---|---|
| protected | SSLContext(SSLContextSpi
the delegate contextSpi, Provider the provider provider, String the protocol protocol)Creates an SSLContext object. |
| Modifier and Type | Method and Description |
|---|---|
| public final SSLEngine | |
| public final SSLEngine | Returns: the newSSLEngine objectthe non-authoritative name of the host peerHost, int the non-authoritative port peerPort)Creates a new |
| public final SSLSessionContext | Returns: client session context bound to this SSL contextReturns the client session context, which represents the set of SSL sessions available for use during the handshake phase of client-side SSL sockets. |
| public static SSLContext | |
| public final SSLParameters | Returns: a copy of the SSLParameters object with the default settingsReturns a copy of the SSLParameters indicating the default settings for this SSL context. |
| public static SSLContext | Returns: the newSSLContext objectthe standard name of the requested protocol.
See the SSLContext section in the
Java Security Standard Algorithm Names Specification
for information about standard protocol names. protocol)Returns a |
| public static SSLContext | Returns: the newSSLContext objectthe standard name of the requested protocol.
See the SSLContext section in the
Java Security Standard Algorithm Names Specification
for information about standard protocol names. protocol, String the name of the provider. provider)Returns a |
| public static SSLContext | Returns: the newSSLContext objectthe standard name of the requested protocol.
See the SSLContext section in the
Java Security Standard Algorithm Names Specification
for information about standard protocol names. protocol, Provider an instance of the provider. provider)Returns a |
| public final String | Returns: the protocol name of thisSSLContext object.Returns the protocol name of this |
| public final Provider | Returns: the provider of thisSSLContext objectReturns the provider of this |
| public final SSLSessionContext | Returns: server session context bound to this SSL contextReturns the server session context, which represents the set of SSL sessions available for use during the handshake phase of server-side SSL sockets. |
| public final SSLServerSocketFactory | Returns: theServerSocketFactory objectReturns a |
| public final SSLSocketFactory | |
| public final SSLParameters | Returns: a copy of the SSLParameters object with the supported settingsReturns a copy of the SSLParameters indicating the supported settings for this SSL context. |
| public final void | init(KeyManager[]
the sources of authentication keys or null km, TrustManager[] the sources of peer authentication trust decisions or null tm, SecureRandom the source of randomness for this generator or null random)Initializes this context. |
| public static void |
| contextSpi | back to summary |
|---|---|
| private final SSLContextSpi contextSpi | |
| defaultContext | back to summary |
|---|---|
| private static volatile SSLContext defaultContext | |
| protocol | back to summary |
|---|---|
| private final String protocol | |
| provider | back to summary |
|---|---|
| private final Provider provider | |
| VH_DEFAULT_CONTEXT | back to summary |
|---|---|
| private static final VarHandle VH_DEFAULT_CONTEXT | |
| SSLContext | back to summary |
|---|---|
| protected SSLContext(SSLContextSpi contextSpi, Provider provider, String protocol) Creates an SSLContext object.
| |
| createSSLEngine | back to summary |
|---|---|
| public final SSLEngine createSSLEngine() Creates a new
Applications using this factory method are providing no hints
for an internal session reuse strategy. If hints are desired,
Some cipher suites (such as Kerberos) require remote hostname information, in which case this factory method should not be used. Implementation Note It is provider-specific if the returned SSLEngine uses client or
server mode by default for the (D)TLS connection. The JDK SunJSSE
provider implementation uses server mode by default. However, it
is recommended to always set the desired mode explicitly by calling
| |
| createSSLEngine | back to summary |
|---|---|
| public final SSLEngine createSSLEngine(String peerHost, int peerPort) Creates a new Applications using this factory method are providing hints for an internal session reuse strategy. Some cipher suites (such as Kerberos) require remote hostname information, in which case peerHost needs to be specified. Implementation Note It is provider-specific if the returned SSLEngine uses client or
server mode by default for the (D)TLS connection. The JDK SunJSSE
provider implementation uses server mode by default. However, it
is recommended to always set the desired mode explicitly by calling
| |
| getClientSessionContext | back to summary |
|---|---|
| public final SSLSessionContext getClientSessionContext() Returns the client session context, which represents the set of SSL sessions available for use during the handshake phase of client-side SSL sockets. This context may be unavailable in some environments, in which case this method returns null. For example, when the underlying SSL provider does not provide an implementation of SSLSessionContext interface, this method returns null. A non-null session context is returned otherwise.
| |
| getDefault | back to summary |
|---|---|
| public static SSLContext getDefault() throws NoSuchAlgorithmException Returns the default SSL context. If a default context was set using the The default context is immediately usable and does not require initialization.
| |
| getDefaultSSLParameters | back to summary |
|---|---|
| public final SSLParameters getDefaultSSLParameters() Returns a copy of the SSLParameters indicating the default settings for this SSL context. The parameters will always have the ciphersuites and protocols arrays set to non-null values.
| |
| getInstance | back to summary |
|---|---|
| public static SSLContext getInstance(String protocol) throws NoSuchAlgorithmException Returns a 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. Note that the list of registered providers may be retrieved via
the Implementation Note The JDK Reference Implementation additionally uses the
| |
| getInstance | back to summary |
|---|---|
| public static SSLContext getInstance(String protocol, String provider) throws NoSuchAlgorithmException, NoSuchProviderException Returns a A new SSLContext object encapsulating the SSLContextSpi implementation from the specified provider is returned. The specified provider must be registered in the security provider list. Note that the list of registered providers may be retrieved via
the
| |
| getInstance | back to summary |
|---|---|
| public static SSLContext getInstance(String protocol, Provider provider) throws NoSuchAlgorithmException Returns a A new SSLContext object encapsulating the SSLContextSpi implementation from the specified Provider object is returned. Note that the specified Provider object does not have to be registered in the provider list.
| |
| getProtocol | back to summary |
|---|---|
| public final String getProtocol() Returns the protocol name of this This is the same name that was specified in one of the
| |
| getProvider | back to summary |
|---|---|
| public final Provider getProvider() Returns the provider of this
| |
| getServerSessionContext | back to summary |
|---|---|
| public final SSLSessionContext getServerSessionContext() Returns the server session context, which represents the set of SSL sessions available for use during the handshake phase of server-side SSL sockets. This context may be unavailable in some environments, in which case this method returns null. For example, when the underlying SSL provider does not provide an implementation of SSLSessionContext interface, this method returns null. A non-null session context is returned otherwise.
| |
| getServerSocketFactory | back to summary |
|---|---|
| public final SSLServerSocketFactory getServerSocketFactory() Returns a
| |
| getSocketFactory | back to summary |
|---|---|
| public final SSLSocketFactory getSocketFactory() Returns a
| |
| getSupportedSSLParameters | back to summary |
|---|---|
| public final SSLParameters getSupportedSSLParameters() Returns a copy of the SSLParameters indicating the supported settings for this SSL context. The parameters will always have the ciphersuites and protocols arrays set to non-null values.
| |
| init | back to summary |
|---|---|
| public final void init(KeyManager[] km, TrustManager[] tm, SecureRandom random) throws KeyManagementException Initializes this context. Either of the first two parameters may be null in which case the installed security providers will be searched for the highest priority implementation of the appropriate factory. Likewise, the secure random parameter may be null in which case the default implementation will be used. 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.)
| |
| setDefault | back to summary |
|---|---|
| public static void setDefault(SSLContext context) Sets the default SSL context. It will be returned by subsequent calls
to
| |