Top Description Inners Fields Constructors Methods
org.apache.tomcat.util.net.openssl

public final Class OpenSSLEngine

extends SSLEngine
implements ProtocolInfo
Class Inheritance
All Implemented Interfaces
org.apache.tomcat.util.net.SSLUtil.ProtocolInfo
Imports
java.lang.ref.Cleaner, .Cleaner.Cleanable, java.nio.ByteBuffer, .ReadOnlyBufferException, java.security.Principal, java.security.cert.Certificate, java.util.ArrayList, .Collections, .HashMap, .HashSet, .LinkedHashSet, .List, .Map, .Set, javax.net.ssl.SSLEngine, .SSLEngineResult, .SSLException, .SSLPeerUnverifiedException, .SSLSession, .SSLSessionBindingEvent, .SSLSessionBindingListener, .SSLSessionContext, org.apache.juli.logging.Log, .LogFactory, org.apache.tomcat.jni.Buffer, .Pool, .SSL, .SSLContext, org.apache.tomcat.util.buf.ByteBufferUtils, org.apache.tomcat.util.net.Constants, .SSLUtil, org.apache.tomcat.util.net.openssl.ciphers.OpenSSLCipherConfigurationParser, org.apache.tomcat.util.res.StringManager

Implements a SSLEngine using OpenSSL BIO abstractions.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static enum
pack-priv static enum
private class
private static class

Field Summary

Modifier and TypeField and Description
private OpenSSLEngine.Accepted
private final boolean
private volatile String
public static final Set<String>
private final int
private final boolean
private volatile String
private final Cleaner.Cleanable
private volatile OpenSSLEngine.ClientAuthMode
private final boolean
private int
private volatile boolean
private static final long
private static final Certificate[]
private boolean
private final String
private boolean
public static final Set<String>
private final boolean
private static final String
private boolean
private boolean
private static final Log
private static final int
private static final int
pack-priv static final int
pack-priv static final int
private static final int
private volatile Certificate[]
private boolean
private String
private boolean
private final OpenSSLEngine.OpenSSLSession
private final OpenSSLSessionContext
private static final StringManager
private final OpenSSLEngine.OpenSSLState
pack-priv static final int
private volatile String
private volatile X509Certificate[]
x509PeerCerts

Deprecated

Constructor Summary

AccessConstructor and Description
pack-priv
OpenSSLEngine(Cleaner
Used to clean up references to instances before they are garbage collected
cleaner
,
long
an OpenSSL SSL_CTX object
sslCtx
,
String
the fallback application protocol
fallbackApplicationProtocol
,
boolean
true if this is used for clients, false otherwise
clientMode
,
OpenSSLSessionContext
the OpenSSLSessionContext this SSLEngine belongs to.
sessionContext
,
boolean
true if alpn should be used, false otherwise
alpn
,
boolean
true if this instance gets its protocol, cipher and client verification from the SSL_CTX sslCtx
initialized
,
int
Certificate verification depth
certificateVerificationDepth
,
boolean
Skip CA verification in optional mode
certificateVerificationOptionalNoCA
)

Creates a new instance

Method Summary

Modifier and TypeMethod and Description
public synchronized void
beginHandshake()

Implements abstract javax.net.ssl.SSLEngine.beginHandshake.

Initiates handshaking (initial or renegotiation) on this SSLEngine.

private void
private void
private static void
clearLastError()

Clear out any errors, but log a warning.

public synchronized void
closeInbound()

Implements abstract javax.net.ssl.SSLEngine.closeInbound.

Signals that no more inbound network data will be sent to this SSLEngine.

public synchronized void
closeOutbound()

Implements abstract javax.net.ssl.SSLEngine.closeOutbound.

Signals that no more outbound application data will be sent on this SSLEngine.

public Runnable
getDelegatedTask()

Implements abstract javax.net.ssl.SSLEngine.getDelegatedTask.

Returns a delegated Runnable task for this SSLEngine.

public synchronized String[]
getEnabledCipherSuites()

Implements abstract javax.net.ssl.SSLEngine.getEnabledCipherSuites.

Returns the names of the SSL cipher suites which are currently enabled for use on this engine.

public synchronized String[]
getEnabledProtocols()

Implements abstract javax.net.ssl.SSLEngine.getEnabledProtocols.

Returns the names of the protocol versions which are currently enabled for use with this SSLEngine.

public boolean
getEnableSessionCreation()

Implements abstract javax.net.ssl.SSLEngine.getEnableSessionCreation.

Returns true if new SSL sessions may be established by this engine.

private SSLEngineResult.Status
public synchronized SSLEngineResult.HandshakeStatus
getHandshakeStatus()

Implements abstract javax.net.ssl.SSLEngine.getHandshakeStatus.

Returns the current handshake status for this SSLEngine.

private static String

Returns:

the first error in the stack
getLastError
()

Many calls to SSL methods do not check the last error.

public boolean
getNeedClientAuth()

Implements abstract javax.net.ssl.SSLEngine.getNeedClientAuth.

Returns true if the engine will require client authentication.

public String
public SSLSession
getSession()

Implements abstract javax.net.ssl.SSLEngine.getSession.

Returns the SSLSession in use in this SSLEngine.

public String[]
getSupportedCipherSuites()

Implements abstract javax.net.ssl.SSLEngine.getSupportedCipherSuites.

Returns the names of the cipher suites which could be enabled for use on this engine.

public String[]
getSupportedProtocols()

Implements abstract javax.net.ssl.SSLEngine.getSupportedProtocols.

Returns the names of the protocols which could be enabled for use with this SSLEngine.

public boolean
getUseClientMode()

Implements abstract javax.net.ssl.SSLEngine.getUseClientMode.

Returns true if the engine is set to use client mode when handshaking.

public boolean
getWantClientAuth()

Implements abstract javax.net.ssl.SSLEngine.getWantClientAuth.

Returns true if the engine will request client authentication.

private void
public synchronized boolean
isInboundDone()

Implements abstract javax.net.ssl.SSLEngine.isInboundDone.

Returns whether unwrap(ByteBuffer, ByteBuffer) will accept any more inbound data messages.

public synchronized boolean
isOutboundDone()

Implements abstract javax.net.ssl.SSLEngine.isOutboundDone.

Returns whether wrap(ByteBuffer, ByteBuffer) will produce any more outbound data messages.

private int
private int
readEncryptedData(final long networkBIO, final ByteBuffer dst, final int pending)

Read encrypted data from the OpenSSL network BIO

private int
readPlaintextData(final long ssl, final ByteBuffer dst)

Read plain text data from the OpenSSL internal BIO

private synchronized void
private void
public synchronized void
setEnabledCipherSuites(String[]
Names of all the cipher suites to enable
cipherSuites
)

Implements abstract javax.net.ssl.SSLEngine.setEnabledCipherSuites.

Sets the cipher suites enabled for use on this engine.

public synchronized void
setEnabledProtocols(String[]
Names of all the protocols to enable.
protocols
)

Implements abstract javax.net.ssl.SSLEngine.setEnabledProtocols.

Set the protocol versions enabled for use on this engine.

public void
setEnableSessionCreation(boolean
true indicates that sessions may be created; this is the default. false indicates that an existing session must be resumed
b
)

Implements abstract javax.net.ssl.SSLEngine.setEnableSessionCreation.

Controls whether new SSL sessions may be established by this engine.

public void
setNeedClientAuth(boolean
set to true if client authentication is required, or false if no client authentication is desired.
b
)

Implements abstract javax.net.ssl.SSLEngine.setNeedClientAuth.

Configures the engine to require client authentication.

public void
setUseClientMode(boolean
true if the engine should start its handshaking in "client" mode
clientMode
)

Implements abstract javax.net.ssl.SSLEngine.setUseClientMode.

Configures the engine to use client (or server) mode when handshaking.

public void
setWantClientAuth(boolean
set to true if client authentication is requested, or false if no client authentication is desired.
b
)

Implements abstract javax.net.ssl.SSLEngine.setWantClientAuth.

Configures the engine to request client authentication.

public synchronized void
shutdown()

Destroys this engine.

public synchronized SSLEngineResult
unwrap(final ByteBuffer
a ByteBuffer containing inbound network data.
src
,
final ByteBuffer[]
an array of ByteBuffers to hold inbound application data.
dsts
,
final int
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 dsts.length.
offset
,
final int
The maximum number of buffers to be accessed; it must be non-negative and no larger than dsts.length - offset.
length
)

Implements abstract javax.net.ssl.SSLEngine.unwrap.

Attempts to decode SSL/TLS/DTLS network data into a subsequence of plaintext application data buffers.

public synchronized SSLEngineResult
wrap(final ByteBuffer[]
an array of ByteBuffers containing the outbound application data
srcs
,
final int
The 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 srcs.length
offset
,
final int
The maximum number of buffers to be accessed; it must be non-negative and no larger than srcs.length - offset
length
,
final ByteBuffer
a ByteBuffer to hold outbound network data
dst
)

Implements abstract javax.net.ssl.SSLEngine.wrap.

Attempts to encode plaintext bytes from a subsequence of data buffers into SSL/TLS/DTLS network data.

private int
writeEncryptedData(final long networkBIO, final ByteBuffer src)

Write encrypted data to the OpenSSL network BIO.

private int
writePlaintextData(final long ssl, final ByteBuffer src)

Write plain text data to the OpenSSL internal BIO Calling this function with src.remaining == 0 is undefined.

Inherited from javax.net.ssl.SSLEngine:
getApplicationProtocolgetHandshakeApplicationProtocolgetHandshakeApplicationProtocolSelectorgetHandshakeSessiongetPeerHostgetPeerPortgetSSLParameterssetHandshakeApplicationProtocolSelectorsetSSLParametersunwrapunwrapwrapwrap