Top Description Inners Fields Constructors Methods
org.conscrypt

pack-priv Class ConscryptFileDescriptorSocket

extends OpenSSLSocketImpl
implements SSLHandshakeCallbacks, PSKCallbacks, AliasChooser
Class Inheritance
All Implemented Interfaces
org.conscrypt.SSLParametersImpl.AliasChooser, org.conscrypt.SSLParametersImpl.PSKCallbacks, org.conscrypt.NativeCrypto.SSLHandshakeCallbacks
Known Direct Subclasses
org.conscrypt.Java8FileDescriptorSocket
Static Imports
org.conscrypt.SSLUtils.EngineStates.STATE_CLOSED, .SSLUtils.EngineStates.STATE_HANDSHAKE_COMPLETED, .SSLUtils.EngineStates.STATE_HANDSHAKE_STARTED, .SSLUtils.EngineStates.STATE_NEW, .SSLUtils.EngineStates.STATE_READY, .SSLUtils.EngineStates.STATE_READY_HANDSHAKE_CUT_THROUGH

Implementation of the class OpenSSLSocketImpl based on OpenSSL.

Extensions to SSLSocket include:

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
ConscryptFileDescriptorSocket.SSLInputStream

This inner class provides input data stream functionality for the OpenSSL native implementation.

private class
ConscryptFileDescriptorSocket.SSLOutputStream

This inner class provides output data stream functionality for the OpenSSL native implementation.

Field Summary

Modifier and TypeField and Description
private final ActiveSession
private OpenSSLKey
channelIdPrivateKey

Private key for the TLS Channel ID extension.

private SessionSnapshot
closedSession

A snapshot of the active session when the engine was closed.

private static final boolean
private final SSLSession
externalSession

The session object exposed externally from this class.

private final Object
private int
private ConscryptFileDescriptorSocket.SSLInputStream
is

Protected by synchronizing on ssl.

private ConscryptFileDescriptorSocket.SSLOutputStream
os

Protected by synchronizing on ssl.

private final NativeSsl
ssl

Wrapper around the underlying SSL object.

private final SSLParametersImpl
private int
private int

Constructor Summary

AccessConstructor and Description
pack-priv
pack-priv
ConscryptFileDescriptorSocket(String hostname, int port, SSLParametersImpl sslParameters)

pack-priv
pack-priv
ConscryptFileDescriptorSocket(String hostname, int port, InetAddress clientAddress, int clientPort, SSLParametersImpl sslParameters)

pack-priv
ConscryptFileDescriptorSocket(InetAddress address, int port, InetAddress clientAddress, int clientPort, SSLParametersImpl sslParameters)

pack-priv
ConscryptFileDescriptorSocket(Socket socket, String hostname, int port, boolean autoClose, SSLParametersImpl sslParameters)

Method Summary

Modifier and TypeMethod and Description
private void
public final String
public final String
chooseClientPSKIdentity(PSKKeyManager keyManager, String identityHint)

Implements org.conscrypt.SSLParametersImpl.PSKCallbacks.chooseClientPSKIdentity.

Deprecated as a consequence of PSKKeyManager being deprecated.
public final String
public final String
public final void
clientCertificateRequested(byte[]
key types supported by the server, convertible to strings with #keyType
keyTypeBytes
,
int[] signatureAlgs, byte[][]
CAs known to the server
asn1DerEncodedPrincipals
)

Implements org.conscrypt.NativeCrypto.SSLHandshakeCallbacks.clientCertificateRequested.

Called on an SSL client when the server requests (or requires a certificate).
public final int
clientPSKKeyRequested(String
PSK identity hint provided by the server or null if no hint provided.
identityHint
,
byte[]
buffer to be populated with PSK identity (NULL-terminated modified UTF-8) by this method. This identity will be provided to the server.
identity
,
byte[]
buffer to be populated with key material by this method.
key
)

Implements org.conscrypt.NativeCrypto.SSLHandshakeCallbacks.clientPSKKeyRequested.

Gets the key to be used in client mode for this connection in Pre-Shared Key (PSK) key exchange.
private ClientSessionContext
public final void
private void
pack-priv byte[]
exportKeyingMaterial(String
the label to use in calculating the exported value. This must be an ASCII-only string.
label
,
byte[]
the application-specific context value to use in calculating the exported value. This may be null to use no application context, which is treated differently than an empty byte array.
context
,
int
the number of bytes of keying material to return.
length
)

Implements abstract org.conscrypt.AbstractConscryptSocket.exportKeyingMaterial.

Exports a value derived from the TLS master secret as described in RFC 5705.
protected final void
finalize()

Overrides java.lang.Object.finalize.

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
private void
free()

pack-priv final SSLSession
getActiveSession()

Implements abstract org.conscrypt.AbstractConscryptSocket.getActiveSession.

Called by notifyHandshakeCompletedListeners() to get the currently active session.
public final String
getApplicationProtocol()

Implements abstract org.conscrypt.AbstractConscryptSocket.getApplicationProtocol.

Returns the most recent application protocol value negotiated for this connection.
pack-priv final String[]
getApplicationProtocols()

Implements abstract org.conscrypt.AbstractConscryptSocket.getApplicationProtocols.

Returns the list of supported ALPN protocols.
public final byte[]

Returns:

channel ID or null if not available.
getChannelId
()

Implements abstract org.conscrypt.OpenSSLSocketImpl.getChannelId.

Gets the TLS Channel ID for this server socket.
public final String[]
getEnabledCipherSuites()

Implements abstract javax.net.ssl.SSLSocket.getEnabledCipherSuites.

Returns the names of the SSL cipher suites which are currently enabled for use on this connection.
public final String[]
getEnabledProtocols()

Implements abstract javax.net.ssl.SSLSocket.getEnabledProtocols.

Returns the names of the protocol versions which are currently enabled for use on this connection.
public final boolean
getEnableSessionCreation()

Implements abstract javax.net.ssl.SSLSocket.getEnableSessionCreation.

Returns true if new SSL sessions may be established by this socket.
public final String
getHandshakeApplicationProtocol()

Implements abstract org.conscrypt.AbstractConscryptSocket.getHandshakeApplicationProtocol.

Returns the application protocol value negotiated on a SSL/TLS handshake currently in progress.
public final SSLSession
getHandshakeSession()

Implements abstract org.conscrypt.OpenSSLSocketImpl.getHandshakeSession.

Returns the SSLSession being constructed during a SSL/TLS handshake.
public final InputStream
getInputStream()

Overrides org.conscrypt.AbstractConscryptSocket.getInputStream.

Returns an input stream for this socket.
public final boolean
getNeedClientAuth()

Implements abstract javax.net.ssl.SSLSocket.getNeedClientAuth.

Returns true if the socket will require client authentication.
public final OutputStream
getOutputStream()

Overrides org.conscrypt.AbstractConscryptSocket.getOutputStream.

Returns an output stream for this socket.
public final SecretKey
getPSKKey(PSKKeyManager keyManager, String identityHint, String identity)

Implements org.conscrypt.SSLParametersImpl.PSKCallbacks.getPSKKey.

Deprecated as a consequence of PSKKeyManager being deprecated.
public final SSLSession
getSession()

Implements abstract javax.net.ssl.SSLSocket.getSession.

Returns the SSL Session in use by this connection.
public final int
getSoWriteTimeout()

Overrides org.conscrypt.OpenSSLSocketImpl.getSoWriteTimeout.

Note write timeouts are not part of the javax.net.ssl.SSLSocket API
public final SSLParameters
getSSLParameters()

Overrides javax.net.ssl.SSLSocket.getSSLParameters.

Returns the SSLParameters in effect for this SSLSocket.
public final String[]
getSupportedCipherSuites()

Implements abstract javax.net.ssl.SSLSocket.getSupportedCipherSuites.

Returns the names of the cipher suites which could be enabled for use on this connection.
public final String[]
getSupportedProtocols()

Implements abstract javax.net.ssl.SSLSocket.getSupportedProtocols.

Returns the names of the protocols which could be enabled for use on an SSL connection.
pack-priv byte[]
getTlsUnique()

Implements abstract org.conscrypt.AbstractConscryptSocket.getTlsUnique.

Returns the tls-unique channel binding value for this connection, per RFC 5929.
public final boolean
getUseClientMode()

Implements abstract javax.net.ssl.SSLSocket.getUseClientMode.

Returns true if the socket is set to use client mode when handshaking.
public final boolean
getWantClientAuth()

Implements abstract javax.net.ssl.SSLSocket.getWantClientAuth.

Returns true if the socket will request client authentication.
private static NativeSsl
public final void
onNewSessionEstablished(long sslSessionNativePtr)

Implements org.conscrypt.NativeCrypto.SSLHandshakeCallbacks.onNewSessionEstablished.

Called when a new session has been established and may be added to the session cache.
public final void
onSSLStateChange(int type, int val)

Implements org.conscrypt.NativeCrypto.SSLHandshakeCallbacks.onSSLStateChange.

Called when SSL state changes.
private ConscryptSession
private ConscryptSession
private ConscryptSession
public int
selectApplicationProtocol(byte[]
list of application protocols in length-prefix format
protocols
)

Implements org.conscrypt.NativeCrypto.SSLHandshakeCallbacks.selectApplicationProtocol.

Called when acting as a server, the socket has an ApplicationProtocolSelectorAdapter associated with it, and the application protocol needs to be selected.
public final void
serverCertificateRequested()

Implements org.conscrypt.NativeCrypto.SSLHandshakeCallbacks.serverCertificateRequested.

Called when acting as a server during ClientHello processing before a decision to resume a session is made.
public final int
serverPSKKeyRequested(String
PSK identity hint provided by this server to the client or null if no hint was provided.
identityHint
,
String
PSK identity provided by the client.
identity
,
byte[]
buffer to be populated with key material by this method.
key
)

Implements org.conscrypt.NativeCrypto.SSLHandshakeCallbacks.serverPSKKeyRequested.

Gets the key to be used in server mode for this connection in Pre-Shared Key (PSK) key exchange.
public final long
serverSessionRequested(byte[]
the ID of the session to find.
id
)

Implements org.conscrypt.NativeCrypto.SSLHandshakeCallbacks.serverSessionRequested.

Called for servers where TLS < 1.3 (TLS 1.3 uses session tickets rather than application session caches).
private AbstractSessionContext
pack-priv final void
setApplicationProtocols(String[]
the list of ALPN protocols
protocols
)

Implements abstract org.conscrypt.AbstractConscryptSocket.setApplicationProtocols.

Sets the list of ALPN protocols.
public final void
setApplicationProtocolSelector(ApplicationProtocolSelector selector)

Implements abstract org.conscrypt.AbstractConscryptSocket.setApplicationProtocolSelector.

Sets an application-provided ALPN protocol selector.
pack-priv final void
public final void
setChannelIdEnabled(boolean enabled)

Implements abstract org.conscrypt.OpenSSLSocketImpl.setChannelIdEnabled.

Enables/disables TLS Channel ID for this server socket.
public final void
setChannelIdPrivateKey(PrivateKey
private key (enables TLS Channel ID) or null for no key (disables TLS Channel ID). The private key must be an Elliptic Curve (EC) key based on the NIST P-256 curve (aka SECG secp256r1 or ANSI X9.62 prime256v1).
privateKey
)

Implements abstract org.conscrypt.OpenSSLSocketImpl.setChannelIdPrivateKey.

Sets the PrivateKey to be used for TLS Channel ID by this client socket.
public final void
setEnabledCipherSuites(String[]
Names of all the cipher suites to enable
suites
)

Implements abstract javax.net.ssl.SSLSocket.setEnabledCipherSuites.

Sets the cipher suites enabled for use on this connection.
public final void
setEnabledProtocols(String[]
Names of all the protocols to enable.
protocols
)

Implements abstract javax.net.ssl.SSLSocket.setEnabledProtocols.

Sets the protocol versions enabled for use on this connection.
public final void
setEnableSessionCreation(boolean
true indicates that sessions may be created; this is the default. false indicates that an existing session must be resumed
flag
)

Implements abstract javax.net.ssl.SSLSocket.setEnableSessionCreation.

Controls whether new SSL sessions may be established by this socket.
public final void
setHandshakeTimeout(int handshakeTimeoutMilliseconds)

Overrides org.conscrypt.OpenSSLSocketImpl.setHandshakeTimeout.

Set the handshake timeout on this socket.
public final void
setHostname(String
the desired SNI hostname, or null to disable
hostname
)

Overrides org.conscrypt.OpenSSLSocketImpl.setHostname.

This method enables Server Name Indication.
public final void
setNeedClientAuth(boolean
set to true if client authentication is required, or false if no client authentication is desired.
need
)

Implements abstract javax.net.ssl.SSLSocket.setNeedClientAuth.

Configures the socket to require client authentication.
public final void
setSoWriteTimeout(int writeTimeoutMilliseconds)

Overrides org.conscrypt.OpenSSLSocketImpl.setSoWriteTimeout.

Note write timeouts are not part of the javax.net.ssl.SSLSocket API
public final void
setSSLParameters(SSLParameters
the parameters
p
)

Overrides javax.net.ssl.SSLSocket.setSSLParameters.

Applies SSLParameters to this socket.
public final void
setUseClientMode(boolean
true if the socket should start its handshaking in "client" mode
mode
)

Implements abstract javax.net.ssl.SSLSocket.setUseClientMode.

Configures the socket to use client (or server) mode when handshaking.
public final void
setUseSessionTickets(boolean
True to enable session tickets
useSessionTickets
)

Implements abstract org.conscrypt.OpenSSLSocketImpl.setUseSessionTickets.

This method enables session ticket support.
public final void
setWantClientAuth(boolean
set to true if client authentication is requested, or false if no client authentication is desired.
want
)

Implements abstract javax.net.ssl.SSLSocket.setWantClientAuth.

Configures the socket to request client authentication.
private void
public final void
startHandshake()

Implements abstract javax.net.ssl.SSLSocket.startHandshake.

Starts a TLS/SSL handshake on this connection using some native methods from the OpenSSL library.
private void
transitionTo(int newState)

public final void
verifyCertificateChain(byte[][]
chain of X.509 certificates in their encoded form
certChain
,
String
auth algorithm name
authMethod
)

Implements org.conscrypt.NativeCrypto.SSLHandshakeCallbacks.verifyCertificateChain.

Verify that the certificate chain is trusted.
private void
Inherited from org.conscrypt.OpenSSLSocketImpl:
getAlpnSelectedProtocolgetFileDescriptor$getHostnamegetHostnameOrIPgetNpnSelectedProtocolsetAlpnProtocolssetAlpnProtocolssetNpnProtocols