The secure communications modes include:
The cipher suite used is established by a negotiation process called
"handshaking". The goal of this process is to create or rejoin a
"session", which may protect many connections over time. After
handshaking has completed, you can access session attributes by
using the getSession() method.
The SSLSocket class provides much of the same security
functionality, but all the inbound and outbound data is
automatically transported using the underlying Socket, which by design uses a blocking model.
While this is appropriate for many applications, this model does not
provide the scalability required by large servers.
The primary distinction of an SSLEngine is that it
operates on inbound and outbound byte streams, independent of the
transport mechanism. It is the responsibility of the
SSLEngine user to arrange for reliable I/O transport to
the peer. By separating the SSL/TLS/DTLS abstraction from the I/O
transport mechanism, the SSLEngine can be used for a
wide variety of I/O types, such as non-blocking I/O (polling), selectable non-blocking I/O, Socket and the
traditional Input/OutputStreams, local ByteBuffers or byte arrays, future asynchronous
I/O models , and so on.
At a high level, the SSLEngine appears thus:
app data
| ^
| | |
v | |
+----+-----|-----+----+
| | |
| SSL|Engine |
wrap() | | | unwrap()
| OUTBOUND | INBOUND |
| | |
+----+-----|-----+----+
| | ^
| | |
v |
net data
Application data (also known as plaintext or cleartext) is data which
is produced or consumed by an application. Its counterpart is
network data, which consists of either handshaking and/or ciphertext
(encrypted) data, and destined to be transported via an I/O
mechanism. Inbound data is data which has been received from the
peer, and outbound data is destined for the peer.
(In the context of an SSLEngine, the term "handshake
data" is taken to mean any data exchanged to establish and control a
secure connection. Handshake data includes the SSL/TLS/DTLS messages
"alert", "change_cipher_spec," and "handshake.")
There are five distinct phases to an SSLEngine.
SSLEngine has been created and
initialized, but has not yet been used. During this phase, an
application may set any SSLEngine-specific settings
(enabled cipher suites, whether the SSLEngine should
handshake in client or server mode, and so on). Once
handshaking has begun, though, any new settings (except
client/server mode, see below) will be used for
the next handshake.
SSLEngine. Outbound
application messages are encrypted and integrity protected,
and inbound messages reverse the process.
SSLEngine
configuration settings will not be used until the next
handshake.
SSLEngine objects, an
application should call SSLEngine#closeOutbound() and
send any remaining messages to the peer. Likewise, an application
should receive any remaining messages from the peer before calling
SSLEngine#closeInbound(). The underlying transport mechanism
can then be closed after both sides of the SSLEngine have
been closed. If the connection is not closed in an orderly manner
(for example SSLEngine#closeInbound() is called before the
peer's write closure notification has been received), exceptions
will be raised to indicate that an error has occurred. Once an
engine is closed, it is not reusable: a new SSLEngine
must be created.
SSLEngine is created by calling SSLContext#createSSLEngine() from an initialized
SSLContext. Any configuration
parameters should be set before making the first call to
wrap(), unwrap(), or
beginHandshake(). These methods all trigger the
initial handshake.
Data moves through the engine by calling wrap() or unwrap() on outbound or inbound data, respectively. Depending on
the state of the SSLEngine, a wrap() call
may consume application data from the source buffer and may produce
network data in the destination buffer. The outbound data
may contain application and/or handshake data. A call to
unwrap() will examine the source buffer and may
advance the handshake if the data is handshaking information, or
may place application data in the destination buffer if the data
is application. The state of the underlying SSL/TLS/DTLS algorithm
will determine when data is consumed and produced.
Calls to wrap() and unwrap() return an
SSLEngineResult which indicates the status of the
operation, and (optionally) how to interact with the engine to make
progress.
The SSLEngine produces/consumes complete SSL/TLS/DTLS
packets only, and does not store application data internally between
calls to wrap()/unwrap(). Thus input and output
ByteBuffers must be sized appropriately to hold the
maximum record that can be produced. Calls to SSLSession#getPacketBufferSize() and SSLSession#getApplicationBufferSize() should be used to determine
the appropriate buffer sizes. The size of the outbound application
data buffer generally does not matter. If buffer conditions do not
allow for the proper consumption/production of data, the application
must determine (via SSLEngineResult) and correct the
problem, and then try the call again.
For example, unwrap() will return a SSLEngineResult. result if the engine
determines that there is not enough destination buffer space available.
Applications should call SSLSession#getApplicationBufferSize()
and compare that value with the space available in the destination buffer,
enlarging the buffer if necessary. Similarly, if unwrap()
were to return a SSLEngineResult., the
application should call SSLSession#getPacketBufferSize() to ensure
that the source buffer has enough room to hold a record (enlarging if
necessary), and then obtain more inbound data.
SSLEngineResult r = engine.unwrap(src, dst);
switch (r.getStatus()) {
case BUFFER_OVERFLOW:
// Could attempt to drain the dst buffer of any already obtained
// data, but we'll just increase it to the size needed.
int appSize = engine.getSession().getApplicationBufferSize();
ByteBuffer b = ByteBuffer.allocate(appSize + dst.position());
dst.flip();
b.put(dst);
dst = b;
// retry the operation.
break;
case BUFFER_UNDERFLOW:
int netSize = engine.getSession().getPacketBufferSize();
// Resize buffer if needed.
if (netSize > src.capacity()) {
ByteBuffer b = ByteBuffer.allocate(netSize);
src.flip();
b.put(src);
src = b;
}
// Obtain more inbound network data for src,
// then retry the operation.
break;
// other cases: CLOSED, OK.
}
Unlike SSLSocket, all methods of SSLEngine are
non-blocking. SSLEngine implementations may
require the results of tasks that may take an extended period of
time to complete, or may even block. For example, a TrustManager
may need to connect to a remote certificate validation service,
or a KeyManager might need to prompt a user to determine which
certificate to use as part of client authentication. Additionally,
creating cryptographic signatures and verifying them can be slow,
seemingly blocking.
For any operation which may potentially block, the
SSLEngine will create a java.
delegated task. When SSLEngineResult indicates that a
delegated task result is needed, the application must call getDelegatedTask() to obtain an outstanding delegated task and
call its run() method (possibly using
a different thread depending on the compute strategy). The
application should continue obtaining delegated tasks until no more
exist, and try the original operation again.
At the end of a communication session, applications should properly
close the SSL/TLS/DTLS link. The SSL/TLS/DTLS protocols have closure
handshake messages, and these messages should be communicated to the
peer before releasing the SSLEngine and closing the
underlying transport mechanism. A close can be initiated by one of:
an SSLException, an inbound closure handshake message, or one of the
close methods. In all cases, closure handshake messages are
generated by the engine, and wrap() should be repeatedly
called until the resulting SSLEngineResult's status
returns "CLOSED", or isOutboundDone() returns true. All
data obtained from the wrap() method should be sent to the
peer.
closeOutbound() is used to signal the engine that the
application will not be sending any more data.
A peer will signal its intent to close by sending its own closure
handshake message. After this message has been received and
processed by the local SSLEngine's unwrap()
call, the application can detect the close by calling
unwrap() and looking for a SSLEngineResult
with status "CLOSED", or if isInboundDone() returns true.
If for some reason the peer closes the communication link without
sending the proper SSL/TLS/DTLS closure message, the application can
detect the end-of-stream and can signal the engine via closeInbound() that there will no more inbound messages to
process. Some applications might choose to require orderly shutdown
messages from a peer, in which case they can check that the closure
was generated by a handshake message and not by an end-of-stream
condition.
There are two groups of cipher suites which you will need to know about when managing cipher suites:
getSupportedCipherSuites().
setEnabledCipherSuites(String[]) method, and
queried using the getEnabledCipherSuites() method.
Initially, a default set of cipher suites will be enabled on a
new engine that represents the minimum suggested
configuration.
Each SSL/TLS/DTLS connection must have one client and one server, thus
each endpoint must decide which role to assume. This choice determines
who begins the handshaking process as well as which type of messages
should be sent by each party. The method setUseClientMode(boolean) configures the mode. Note that the
default mode for a new SSLEngine is provider-specific.
Applications should set the mode explicitly before invoking other
methods of the SSLEngine. Once the initial handshaking has
started, an SSLEngine can not switch between client and server
modes, even when performing renegotiations.
The ApplicationProtocol String values returned by the methods
in this class are in the network byte representation sent by the peer.
The bytes could be directly compared, or converted to its Unicode
String format for comparison.
String networkString = sslEngine.getHandshakeApplicationProtocol();
byte[] bytes = networkString.getBytes(StandardCharsets.ISO_8859_1);
//
// Match using bytes:
//
// "http/1.1" (7-bit ASCII values same in UTF-8)
// MEETEI MAYEK LETTERS "HUK UN I" (Unicode 0xabcd->0xabcf)
//
String HTTP1_1 = "http/1.1";
byte[] HTTP1_1_BYTES = HTTP1_1.getBytes(StandardCharsets.UTF_8);
byte[] HUK_UN_I_BYTES = new byte[] {
(byte) 0xab, (byte) 0xcd,
(byte) 0xab, (byte) 0xce,
(byte) 0xab, (byte) 0xcf};
if ((Arrays.compare(bytes, HTTP1_1_BYTES) == 0 )
|| Arrays.compare(bytes, HUK_UN_I_BYTES) == 0) {
...
}
//
// Alternatively match using string.equals() if we know the ALPN value
// was encoded from a String using a certain character set,
// for example UTF-8. The ALPN value must first be properly
// decoded to a Unicode String before use.
//
String unicodeString = new String(bytes, StandardCharsets.UTF_8);
if (unicodeString.equals(HTTP1_1)
|| unicodeString.equals("\uabcd\uabce\uabcf")) {
...
}
wrap() and unwrap() methods
may execute concurrently of each other.
For example:
synchronized (outboundLock) {
sslEngine.wrap(src, dst);
outboundQueue.put(dst);
}
As a corollary, two threads must not attempt to call the same method
(either wrap() or unwrap()) concurrently,
because there is no way to guarantee the eventual packet ordering.
SSLContext, SSLSocket, SSLServerSocket, SSLSession, java.net.Socket
| Access | Constructor and Description |
|---|---|
| protected | |
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public abstract void | |
| public abstract void | |
| public abstract void | |
| public String | Returns: null if it has not yet been determined if application protocols might be used for this connection, an emptyString if application protocols values will not
be used, or a non-empty application protocol String
if a value was successfully negotiated.Returns the most recent application protocol value negotiated for this connection. |
| public abstract Runnable | Returns: a delegatedRunnable task, or null
if none are available.Returns a delegated |
| public abstract String[] | Returns: an array of cipher suite namesReturns the names of the SSL cipher suites which are currently enabled for use on this engine. |
| public abstract String[] | Returns: an array of protocolsReturns the names of the protocol versions which are currently
enabled for use with this |
| public abstract boolean | Returns: true indicates that sessions may be created; this is the default. false indicates that an existing session must be resumedReturns true if new SSL sessions may be established by this engine. |
| public String | Returns: null if it has not yet been determined if application protocols might be used for this handshake, an emptyString if application protocols values will not
be used, or a non-empty application protocol String
if a value was successfully negotiated.Returns the application protocol value negotiated on a SSL/TLS handshake currently in progress. |
| public BiFunction | Returns: the callback function, or null if none has been set.Retrieves the callback function that selects an application protocol value during a SSL/TLS/DTLS handshake. |
| public SSLSession | Returns: null if this instance is not currently handshaking, or if the current handshake has not progressed far enough to create a basic SSLSession. Otherwise, this method returns theSSLSession currently being negotiated.Returns the |
| public abstract SSLEngineResult. | Returns: the currentSSLEngineResult.HandshakeStatus.Returns the current handshake status for this |
| public abstract boolean | Returns: true if client authentication is required, or false if no client authentication is desired.Returns true if the engine will require client authentication. |
| public String | Returns: the host name of the peer, or null if nothing is available.Returns the host name of the peer. |
| public int | Returns: the port number of the peer, or -1 if nothing is available.Returns the port number of the peer. |
| public abstract SSLSession | Returns: theSSLSession for this SSLEngineReturns the |
| public SSLParameters | Returns: the SSLParameters in effect for this SSLEngine.Returns the SSLParameters in effect for this SSLEngine. |
| public abstract String[] | Returns: an array of cipher suite namesReturns the names of the cipher suites which could be enabled for use on this engine. |
| public abstract String[] | Returns: an array of protocols supportedReturns the names of the protocols which could be enabled for use
with this |
| public abstract boolean | Returns: true if the engine should do handshaking in "client" modeReturns true if the engine is set to use client mode when handshaking. |
| public abstract boolean | Returns: true if client authentication is requested, or false if no client authentication is desired.Returns true if the engine will request client authentication. |
| public abstract boolean | Returns: true if theSSLEngine will not
consume any more network data (and by implication,
will not produce any more application data.)Returns whether |
| public abstract boolean | Returns: true if theSSLEngine will not produce
any more network dataReturns whether |
| public abstract void | setEnabledCipherSuites(String[]
Names of all the cipher suites to enable suites)Sets the cipher suites enabled for use on this engine. |
| public abstract void | setEnabledProtocols(String[]
Names of all the protocols to enable. protocols)Set the protocol versions enabled for use on this engine. |
| public abstract void | setEnableSessionCreation(boolean
true indicates that sessions may be created; this
is the default. false indicates that an existing session
must be resumed flag)Controls whether new SSL sessions may be established by this engine. |
| public void | setHandshakeApplicationProtocolSelector(BiFunction<SSLEngine, List<String>, String>
the callback function, or null to disable the callback
functionality. selector)Registers a callback function that selects an application protocol value for a SSL/TLS/DTLS handshake. |
| public abstract void | setNeedClientAuth(boolean
set to true if client authentication is required,
or false if no client authentication is desired. need)Configures the engine to require client authentication. |
| public void | |
| public abstract void | setUseClientMode(boolean
true if the engine should start its handshaking
in "client" mode mode)Configures the engine to use client (or server) mode when handshaking. |
| public abstract void | setWantClientAuth(boolean
set to true if client authentication is requested,
or false if no client authentication is desired. want)Configures the engine to request client authentication. |
| public SSLEngineResult | Returns: anSSLEngineResult describing the result
of this operation.a src, ByteBuffer ByteBuffer containing inbound network data.a dst)ByteBuffer to hold inbound application data.Attempts to decode SSL/TLS/DTLS network data into a plaintext application data buffer. |
| public SSLEngineResult | Returns: anSSLEngineResult describing the result
of this operation.a src, ByteBuffer[] ByteBuffer containing inbound network data.an array of dsts)ByteBuffers to hold inbound
application data.Attempts to decode SSL/TLS/DTLS network data into a sequence of plaintext application data buffers. |
| public abstract SSLEngineResult | Returns: anSSLEngineResult describing the result
of this operation.a src, ByteBuffer[] ByteBuffer containing inbound network data.an array of dsts, int ByteBuffers to hold inbound
application data.The offset within the buffer array of the first buffer from
which bytes are to be transferred; it must be non-negative
and no larger than offset, int dsts.length.The maximum number of buffers to be accessed; it must be
non-negative and no larger than
length)dsts.length - offset.Attempts to decode SSL/TLS/DTLS network data into a subsequence of plaintext application data buffers. |
| public SSLEngineResult | Returns: anSSLEngineResult describing the result
of this operation.a src, ByteBuffer ByteBuffer containing outbound application dataa dst)ByteBuffer to hold outbound network dataAttempts to encode a buffer of plaintext application data into SSL/TLS/DTLS network data. |
| public SSLEngineResult | Returns: anSSLEngineResult describing the result
of this operation.an array of srcs, ByteBuffer ByteBuffers containing the
outbound application dataa dst)ByteBuffer to hold outbound network dataAttempts to encode plaintext bytes from a sequence of data buffers into SSL/TLS/DTLS network data. |
| public abstract SSLEngineResult | Returns: anSSLEngineResult describing the result
of this operation.an array of srcs, int ByteBuffers containing the
outbound application dataThe offset within the buffer array of the first buffer from
which bytes are to be retrieved; it must be non-negative
and no larger than offset, int srcs.lengthThe maximum number of buffers to be accessed; it must be
non-negative and no larger than
length, ByteBuffer srcs.length - offseta dst)ByteBuffer to hold outbound network dataAttempts to encode plaintext bytes from a subsequence of data buffers into SSL/TLS/DTLS network data. |
| peerHost | back to summary |
|---|---|
| private String peerHost | |
| peerPort | back to summary |
|---|---|
| private int peerPort | |
| SSLEngine | back to summary |
|---|---|
| protected SSLEngine() Constructor for an | |
| SSLEngine | back to summary |
|---|---|
| protected SSLEngine(String peerHost, int peerPort) Constructor for an
Some cipher suites (such as Kerberos) require remote hostname information. Implementations of this class should use this constructor to use Kerberos.
The parameters are not authenticated by the
| |
| beginHandshake | back to summary |
|---|---|
| public abstract void beginHandshake() throws SSLException Begins handshaking on this Common reasons include a need to initiate a new protected session, create new encryption keys, or to change cipher suites. To force complete reauthentication, the current session should be invalidated before starting this handshake. The behavior of this method is protocol (and possibly implementation) dependent. For example, in TLSv1.3 calling this method after the connection has been established will force a key update. For prior TLS versions it will force a renegotiation (re-handshake).
This method is not needed for the initial handshake, as the
Note that the peer may also request a session renegotiation with
this
Unlike the
Some protocols may not support multiple handshakes on an existing
engine and may throw an
| |
| closeInbound | back to summary |
|---|---|
| public abstract void closeInbound() throws SSLException Signals that no more inbound network data will be sent
to this
If the application initiated the closing process by calling
But if the application did not initiate the closure process, or if the circumstances above do not apply, this method should be called whenever the end of the SSL/TLS/DTLS data stream is reached. This ensures closure of the inbound side, and checks that the peer followed the SSL/TLS/DTLS close procedure properly, thus detecting possible truncation attacks. This method is idempotent: if the inbound side has already been closed, this method does not do anything.
| |
| closeOutbound | back to summary |
|---|---|
| public abstract void closeOutbound() Signals that no more outbound application data will be sent
on this This method is idempotent: if the outbound side has already been closed, this method does not do anything.
| |
| getApplicationProtocol | back to summary |
|---|---|
| public String getApplicationProtocol() Returns the most recent application protocol value negotiated for this connection. If supported by the underlying SSL/TLS/DTLS implementation, application name negotiation mechanisms such as RFC 7301 , the Application-Layer Protocol Negotiation (ALPN), can negotiate application-level values between peers. Implementation Specification The implementation in this class throws
| |
| getDelegatedTask | back to summary |
|---|---|
| public abstract Runnable getDelegatedTask() Returns a delegated
A call to this method will return each outstanding task exactly once. Multiple delegated tasks can be run in parallel.
| |
| getEnabledCipherSuites | back to summary |
|---|---|
| public abstract String[] getEnabledCipherSuites() Returns the names of the SSL cipher suites which are currently enabled for use on this engine. When an SSLEngine is first created, all enabled cipher suites support a minimum quality of service. Thus, in some environments this value might be empty. Note that even if a suite is enabled, it may never be used. This can occur if the peer does not support it, or its use is restricted, or the requisite certificates (and private keys) for the suite are not available, or an anonymous suite is enabled but authentication is required. The returned array includes cipher suites from the list of standard cipher suite names in the JSSE Cipher Suite Names section of the Java Security Standard Algorithm Names Specification, and may also include other cipher suites that the provider supports.
| |
| getEnabledProtocols | back to summary |
|---|---|
| public abstract String[] getEnabledProtocols() Returns the names of the protocol versions which are currently
enabled for use with this Note that even if a protocol is enabled, it may never be used. This can occur if the peer does not support the protocol, or its use is restricted, or there are no enabled cipher suites supported by the protocol.
| |
| getEnableSessionCreation | back to summary |
|---|---|
| public abstract boolean getEnableSessionCreation() Returns true if new SSL sessions may be established by this engine.
| |
| getHandshakeApplicationProtocol | back to summary |
|---|---|
| public String getHandshakeApplicationProtocol() Returns the application protocol value negotiated on a SSL/TLS handshake currently in progress.
Like Implementation Specification The implementation in this class throws
| |
| getHandshakeApplicationProtocolSelector | back to summary |
|---|---|
| public BiFunction Retrieves the callback function that selects an application protocol
value during a SSL/TLS/DTLS handshake.
See Implementation Specification The implementation in this class throws
| |
| getHandshakeSession | back to summary |
|---|---|
| public SSLSession getHandshakeSession() Returns the
TLS/DTLS protocols may negotiate parameters that are needed when using
an instance of this class, but before the
This method provides early access to the
| |
| getHandshakeStatus | back to summary |
|---|---|
| public abstract SSLEngineResult. Returns the current handshake status for this
| |
| getNeedClientAuth | back to summary |
|---|---|
| public abstract boolean getNeedClientAuth() Returns true if the engine will require client authentication. This option is only useful to engines in the server mode.
| |
| getPeerHost | back to summary |
|---|---|
| public String getPeerHost() Returns the host name of the peer. Note that the value is not authenticated, and should not be relied upon.
| |
| getPeerPort | back to summary |
|---|---|
| public int getPeerPort() Returns the port number of the peer. Note that the value is not authenticated, and should not be relied upon.
| |
| getSession | back to summary |
|---|---|
| public abstract SSLSession getSession() Returns the These can be long-lived, and frequently correspond to an entire login session for some user. The session specifies a particular cipher suite which is being actively used by all connections in that session, as well as the identities of the session's client and server.
Unlike Until the initial handshake has completed, this method returns a session object which reports an invalid cipher suite of "SSL_NULL_WITH_NULL_NULL".
| |
| getSSLParameters | back to summary |
|---|---|
| public SSLParameters getSSLParameters() Returns the SSLParameters in effect for this SSLEngine. The ciphersuites and protocols of the returned SSLParameters are always non-null.
| |
| getSupportedCipherSuites | back to summary |
|---|---|
| public abstract String[] getSupportedCipherSuites() Returns the names of the cipher suites which could be enabled for use on this engine. Normally, only a subset of these will actually be enabled by default, since this list may include cipher suites which do not meet quality of service requirements for those defaults. Such cipher suites might be useful in specialized applications. The returned array includes cipher suites from the list of standard cipher suite names in the JSSE Cipher Suite Names section of the Java Security Standard Algorithm Names Specification, and may also include other cipher suites that the provider supports.
| |
| getSupportedProtocols | back to summary |
|---|---|
| public abstract String[] getSupportedProtocols() Returns the names of the protocols which could be enabled for use
with this
| |
| getUseClientMode | back to summary |
|---|---|
| public abstract boolean getUseClientMode() Returns true if the engine is set to use client mode when handshaking. Implementation Note The JDK SunJSSE provider implementation returns false unless
| |
| getWantClientAuth | back to summary |
|---|---|
| public abstract boolean getWantClientAuth() Returns true if the engine will request client authentication. This option is only useful for engines in the server mode.
| |
| isInboundDone | back to summary |
|---|---|
| public abstract boolean isInboundDone() Returns whether
| |
| isOutboundDone | back to summary |
|---|---|
| public abstract boolean isOutboundDone() Returns whether
Note that during the closure phase, a
| |
| setEnabledCipherSuites | back to summary |
|---|---|
| public abstract void setEnabledCipherSuites(String[] suites) Sets the cipher suites enabled for use on this engine.
Each cipher suite in the Note that the standard list of cipher suite names may be found in the JSSE Cipher Suite Names section of the Java Security Standard Algorithm Names Specification. Providers may support cipher suite names not found in this list or might not use the recommended name for a certain cipher suite.
See
| |
| setEnabledProtocols | back to summary |
|---|---|
| public abstract void setEnabledProtocols(String[] protocols) Set the protocol versions enabled for use on this engine.
The protocols must have been listed by getSupportedProtocols()
as being supported. Following a successful call to this method,
only protocols listed in the
| |
| setEnableSessionCreation | back to summary |
|---|---|
| public abstract void setEnableSessionCreation(boolean flag) Controls whether new SSL sessions may be established by this engine. If session creations are not allowed, and there are no existing sessions to resume, there will be no successful handshaking.
| |
| setHandshakeApplicationProtocolSelector | back to summary |
|---|---|
| public void setHandshakeApplicationProtocolSelector(BiFunction<SSLEngine, List<String>, String> selector) Registers a callback function that selects an application protocol
value for a SSL/TLS/DTLS handshake.
The function overrides any values supplied using
For example, the following call registers a callback function that examines the TLS handshake parameters and selects an application protocol name:
API Note This method should be called by TLS server applications before the TLS
handshake begins. Also, this Implementation Specification The implementation in this class throws
| |
| setNeedClientAuth | back to summary |
|---|---|
| public abstract void setNeedClientAuth(boolean need) Configures the engine to require client authentication. This option is only useful for engines in the server mode. An engine's client authentication setting is one of the following:
Unlike
Calling this method overrides any previous setting made by
this method or
| |
| setSSLParameters | back to summary |
|---|---|
| public void setSSLParameters(SSLParameters params) Applies SSLParameters to this engine. This means:
| |
| setUseClientMode | back to summary |
|---|---|
| public abstract void setUseClientMode(boolean mode) Configures the engine to use client (or server) mode when handshaking. This method must be called before any handshaking occurs. Once handshaking has begun, the mode can not be reset for the life of this engine. Servers normally authenticate themselves, and clients are not required to do so. Implementation Note The JDK SunJSSE provider implementation default for this mode is false.
| |
| setWantClientAuth | back to summary |
|---|---|
| public abstract void setWantClientAuth(boolean want) Configures the engine to request client authentication. This option is only useful for engines in the server mode. An engine's client authentication setting is one of the following:
Unlike
Calling this method overrides any previous setting made by
this method or
| |
| unwrap | back to summary |
|---|---|
| public SSLEngineResult unwrap(ByteBuffer src, ByteBuffer dst) throws SSLException Attempts to decode SSL/TLS/DTLS network data into a plaintext application data buffer. An invocation of this method behaves in exactly the same manner as the invocation:
| |
| unwrap | back to summary |
|---|---|
| public SSLEngineResult unwrap(ByteBuffer src, ByteBuffer[] dsts) throws SSLException Attempts to decode SSL/TLS/DTLS network data into a sequence of plaintext application data buffers. An invocation of this method behaves in exactly the same manner as the invocation:
| |
| unwrap | back to summary |
|---|---|
| public abstract SSLEngineResult unwrap(ByteBuffer src, ByteBuffer[] dsts, int offset, int length) throws SSLException Attempts to decode SSL/TLS/DTLS network data into a subsequence of
plaintext application data buffers. This "scattering"
operation decodes, in a single invocation, a sequence of bytes
into one or more of a given sequence of buffers. Scattering
unwraps are often useful when implementing network protocols or
file formats that, for example, group data into segments
consisting of one or more fixed-length headers followed by a
variable-length body. See
Depending on the state of the SSLEngine, this method may consume network data without producing any application data (for example, it may consume handshake data.) The application is responsible for reliably obtaining the network data from the peer, and for invoking unwrap() on the data in the order it was received. The application must properly synchronize multiple calls to this method.
If this
This method will attempt to consume one complete SSL/TLS/DTLS network
packet, but will never consume more than the sum of the bytes
remaining in the buffers. Each
The underlying memory used by the
The inbound network buffer, Note the network data will not be useful to a second SSLEngine, as each SSLEngine contains unique random state which influences the SSL/TLS/DTLS messages. See the class description for more information on engine closure.
| |
| wrap | back to summary |
|---|---|
| public SSLEngineResult wrap(ByteBuffer src, ByteBuffer dst) throws SSLException Attempts to encode a buffer of plaintext application data into SSL/TLS/DTLS network data. An invocation of this method behaves in exactly the same manner as the invocation:
| |
| wrap | back to summary |
|---|---|
| public SSLEngineResult wrap(ByteBuffer[] srcs, ByteBuffer dst) throws SSLException Attempts to encode plaintext bytes from a sequence of data buffers into SSL/TLS/DTLS network data. An invocation of this method behaves in exactly the same manner as the invocation:
| |
| wrap | back to summary |
|---|---|
| public abstract SSLEngineResult wrap(ByteBuffer[] srcs, int offset, int length, ByteBuffer dst) throws SSLException Attempts to encode plaintext bytes from a subsequence of data
buffers into SSL/TLS/DTLS network data. This "gathering"
operation encodes, in a single invocation, a sequence of bytes
from one or more of a given sequence of buffers. Gathering
wraps are often useful when implementing network protocols or
file formats that, for example, group data into segments
consisting of one or more fixed-length headers followed by a
variable-length body. See
Depending on the state of the SSLEngine, this method may produce network data without consuming any application data (for example, it may generate handshake data.) The application is responsible for reliably transporting the network data to the peer, and for ensuring that data created by multiple calls to wrap() is transported in the same order in which it was generated. The application must properly synchronize multiple calls to this method.
If this
This method will attempt to produce SSL/TLS/DTLS records, and will
consume as much source data as possible, but will never consume
more than the sum of the bytes remaining in each buffer. Each
The underlying memory used by the See the class description for more information on engine closure.
| |