Top Description Fields Constructors Methods
org.conscrypt

pack-priv abstract Class AbstractConscryptSocket

extends SSLSocket
Class Inheritance
Known Direct Subclasses
org.conscrypt.OpenSSLSocketImpl
Static Imports
org.conscrypt.Preconditions.checkArgument, .Preconditions.checkNotNull

Abstract base class for all Conscrypt SSLSocket classes.

Field Summary

Modifier and TypeField and Description
private final boolean
private final List<HandshakeCompletedListener>
private String
peerHostname

The peer's DNS hostname if it was supplied during creation.

private final PeerInfoProvider
private final int
peerPort

The peer's port if it was supplied during creation.

private int
readTimeoutMilliseconds

Local cache of timeout to avoid getsockopt on every read and write for non-wrapped sockets.

pack-priv final Socket

Constructor Summary

AccessConstructor and Description
pack-priv
pack-priv
AbstractConscryptSocket(String hostname, int port)

pack-priv
pack-priv
AbstractConscryptSocket(String hostname, int port, InetAddress clientAddress, int clientPort)

pack-priv
AbstractConscryptSocket(InetAddress address, int port, InetAddress clientAddress, int clientPort)

pack-priv
AbstractConscryptSocket(Socket socket, String hostname, int port, boolean autoClose)

Method Summary

Modifier and TypeMethod and Description
public void
addHandshakeCompletedListener(HandshakeCompletedListener
the HandShake Completed event listener
listener
)

Implements abstract javax.net.ssl.SSLSocket.addHandshakeCompletedListener.

Registers an event listener to receive notifications that an SSL handshake has completed on this connection.
public void
bind(SocketAddress
the SocketAddress to bind to
bindpoint
)

Overrides java.net.Socket.bind.

Binds the socket to a local address.
pack-priv final void
public void
close()

Overrides java.net.Socket.close.

Implements java.io.Closeable.close.

Closes this socket.
public final void
connect(SocketAddress
the SocketAddress
endpoint
)

Overrides java.net.Socket.connect.

Connects this socket to the server.
public final void
connect(SocketAddress
the SocketAddress
endpoint
,
int
the timeout value to be used in milliseconds.
timeout
)

Overrides java.net.Socket.connect.

Try to extract the peer's hostname if it's available from the endpoint address.
pack-priv abstract byte[]

Returns:

a value of the specified length, or null if the handshake has not yet completed or the connection has been closed.
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
)

Exports a value derived from the TLS master secret as described in RFC 5705.

pack-priv abstract SSLSession
getActiveSession()

Called by notifyHandshakeCompletedListeners() to get the currently active session.

pack-priv abstract byte[]
getAlpnSelectedProtocol()

Deprecated use getApplicationProtocol() instead.
Returns the protocol agreed upon by client and server, or null if no protocol was agreed upon.
public abstract String
getApplicationProtocol()

Overrides javax.net.ssl.SSLSocket.getApplicationProtocol.

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

Returns the list of supported ALPN protocols.

public SocketChannel
getChannel()

Overrides java.net.Socket.getChannel.

Returns the unique SocketChannel object associated with this socket, if any.
pack-priv abstract byte[]

Returns:

channel ID or null if not available.
getChannelId
()

Gets the TLS Channel ID for this server socket.

public FileDescriptor
public abstract String
getHandshakeApplicationProtocol()

Overrides javax.net.ssl.SSLSocket.getHandshakeApplicationProtocol.

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

Overrides javax.net.ssl.SSLSocket.getHandshakeSession.

Returns the SSLSession being constructed during a SSL/TLS handshake.
pack-priv String
getHostname()

Returns the hostname that was supplied during socket creation.

pack-priv String
getHostnameOrIP()

For the purposes of an SSLSession, we want a way to represent the supplied hostname or the IP address in a textual representation.

public InetAddress
getInetAddress()

Overrides java.net.Socket.getInetAddress.

Returns the address to which the socket is connected.
public InputStream
getInputStream()

Overrides java.net.Socket.getInputStream.

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

Overrides java.net.Socket.getKeepAlive.

Tests if SO_KEEPALIVE is enabled.
public InetAddress
getLocalAddress()

Overrides java.net.Socket.getLocalAddress.

Gets the local address to which the socket is bound.
public int
getLocalPort()

Overrides java.net.Socket.getLocalPort.

Returns the local port number to which this socket is bound.
public SocketAddress
getLocalSocketAddress()

Overrides java.net.Socket.getLocalSocketAddress.

Returns the address of the endpoint this socket is bound to.
pack-priv byte[]
getNpnSelectedProtocol()

Deprecated NPN is not supported
Returns null always for backward compatibility.
public boolean
getOOBInline()

Overrides java.net.Socket.getOOBInline.

Tests if SO_OOBINLINE is enabled.
public OutputStream
getOutputStream()

Overrides java.net.Socket.getOutputStream.

Returns an output stream for this socket.
public final int
getPort()

Overrides java.net.Socket.getPort.

Returns the remote port number to which this socket is connected.
public int
getReceiveBufferSize()

Overrides java.net.Socket.getReceiveBufferSize.

Gets the value of the SO_RCVBUF option for this Socket, that is the buffer size used by the platform for input on this Socket.
public SocketAddress
getRemoteSocketAddress()

Overrides java.net.Socket.getRemoteSocketAddress.

Returns the address of the endpoint this socket is connected to, or null if it is unconnected.
public boolean
public int
getSendBufferSize()

Overrides java.net.Socket.getSendBufferSize.

Get value of the SO_SNDBUF option for this Socket, that is the buffer size used by the platform for output on this Socket.
public int
getSoLinger()

Overrides java.net.Socket.getSoLinger.

Returns setting for SO_LINGER.
public final int
getSoTimeout()

Overrides java.net.Socket.getSoTimeout.

Returns setting for SO_TIMEOUT.
pack-priv int
getSoWriteTimeout()

Note write timeouts are not part of the javax.net.ssl.SSLSocket API

public boolean
getTcpNoDelay()

Overrides java.net.Socket.getTcpNoDelay.

Tests if TCP_NODELAY is enabled.
pack-priv abstract byte[]
getTlsUnique()

Returns the tls-unique channel binding value for this connection, per RFC 5929.

public int
getTrafficClass()

Overrides java.net.Socket.getTrafficClass.

Gets traffic class or type-of-service in the IP header for packets sent from this Socket

As the underlying network implementation may ignore the traffic class or type-of-service set using setTrafficClass(int) this method may return a different value than was previously set using the setTrafficClass(int) method on this Socket.

public boolean
isBound()

Overrides java.net.Socket.isBound.

Returns the binding state of the socket.
public boolean
isClosed()

Overrides java.net.Socket.isClosed.

Returns the closed state of the socket.
public boolean
isConnected()

Overrides java.net.Socket.isConnected.

Returns the connection state of the socket.
private boolean
public boolean
isInputShutdown()

Overrides java.net.Socket.isInputShutdown.

Returns whether the read-half of the socket connection is closed.
public boolean
isOutputShutdown()

Overrides java.net.Socket.isOutputShutdown.

Returns whether the write-half of the socket connection is closed.
pack-priv final void
pack-priv final PeerInfoProvider
public void
removeHandshakeCompletedListener(HandshakeCompletedListener
the HandShake Completed event listener
listener
)

Implements abstract javax.net.ssl.SSLSocket.removeHandshakeCompletedListener.

Removes a previously registered handshake completion listener.
public final void
sendUrgentData(int
The byte of data to send
data
)

Overrides java.net.Socket.sendUrgentData.

Send one byte of urgent data on the socket.
pack-priv abstract void
setAlpnProtocols(String[]
the list of ALPN protocols
alpnProtocols
)

Deprecated use setApplicationProtocols(String[]) instead.
Sets the list of ALPN protocols.
pack-priv abstract void
setAlpnProtocols(byte[]
the encoded form of the ALPN protocol list
alpnProtocols
)

Deprecated Use setApplicationProtocols(String[]) instead.
Alternate version of setAlpnProtocols(String[]) that directly sets the list of ALPN in the wire-format form used by BoringSSL (length-prefixed 8-bit strings).
pack-priv abstract void
setApplicationProtocols(String[]
the list of ALPN protocols
protocols
)

Sets the list of ALPN protocols.

pack-priv abstract void
pack-priv abstract void
setApplicationProtocolSelector(ApplicationProtocolSelector selector)

Sets an application-provided ALPN protocol selector.

pack-priv abstract void
setChannelIdEnabled(boolean enabled)

Enables/disables TLS Channel ID for this server socket.

pack-priv abstract 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
)

Sets the PrivateKey to be used for TLS Channel ID by this client socket.

pack-priv void
setHandshakeTimeout(int handshakeTimeoutMilliseconds)

Set the handshake timeout on this socket.

pack-priv void
setHostname(String
the desired SNI hostname, or null to disable
hostname
)

This method enables Server Name Indication

public void
setKeepAlive(boolean
whether or not to have socket keep alive turned on.
on
)

Overrides java.net.Socket.setKeepAlive.

Enable/disable SO_KEEPALIVE.
pack-priv void
setNpnProtocols(byte[] npnProtocols)

Deprecated NPN is not supported
This method does nothing and is kept for backward compatibility.
public final void
setOOBInline(boolean
true to enable SO_OOBINLINE, false to disable.
on
)

Overrides java.net.Socket.setOOBInline.

Enable/disable SO_OOBINLINE (receipt of TCP urgent data) By default, this option is disabled and TCP urgent data received on a socket is silently discarded.
public void
setPerformancePreferences(int
An int expressing the relative importance of a short connection time
connectionTime
,
int
An int expressing the relative importance of low latency
latency
,
int
An int expressing the relative importance of high bandwidth
bandwidth
)

Overrides java.net.Socket.setPerformancePreferences.

Sets performance preferences for this socket.
public void
setReceiveBufferSize(int
the size to which to set the receive buffer size. This value must be greater than 0.
size
)

Overrides java.net.Socket.setReceiveBufferSize.

Sets the SO_RCVBUF option to the specified value for this Socket.
public void
setReuseAddress(boolean
whether to enable or disable the socket option
on
)

Overrides java.net.Socket.setReuseAddress.

Enable/disable the SO_REUSEADDR socket option.
public void
setSendBufferSize(int
the size to which to set the send buffer size. This value must be greater than 0.
size
)

Overrides java.net.Socket.setSendBufferSize.

Sets the SO_SNDBUF option to the specified value for this Socket.
public void
setSoLinger(boolean
whether or not to linger on.
on
,
int
how long to linger for, if on is true.
linger
)

Overrides java.net.Socket.setSoLinger.

Enable/disable SO_LINGER with the specified linger time in seconds.
public final void
setSoTimeout(int
the specified timeout, in milliseconds.
readTimeoutMilliseconds
)

Overrides java.net.Socket.setSoTimeout.

Enable/disable SO_TIMEOUT with the specified timeout, in milliseconds.
pack-priv void
setSoWriteTimeout(int writeTimeoutMilliseconds)

Note write timeouts are not part of the javax.net.ssl.SSLSocket API

public void
setTcpNoDelay(boolean
true to enable TCP_NODELAY, false to disable.
on
)

Overrides java.net.Socket.setTcpNoDelay.

Enable/disable TCP_NODELAY (disable/enable Nagle's algorithm).
public void
setTrafficClass(int
an int value for the bitset.
tc
)

Overrides java.net.Socket.setTrafficClass.

Sets traffic class or type-of-service octet in the IP header for packets sent from this Socket.
pack-priv abstract void
setUseSessionTickets(boolean
True to enable session tickets
useSessionTickets
)

This method enables session ticket support.

public void
shutdownInput()

Overrides java.net.Socket.shutdownInput.

Places the input stream for this socket at "end of stream".
public void
shutdownOutput()

Overrides java.net.Socket.shutdownOutput.

Disables the output stream for this socket.
public String
toString()

Overrides java.net.Socket.toString.

Converts this socket to a String.
Inherited from javax.net.ssl.SSLSocket:
getEnabledCipherSuitesgetEnabledProtocolsgetEnableSessionCreationgetHandshakeApplicationProtocolSelectorgetNeedClientAuthgetSessiongetSSLParametersgetSupportedCipherSuitesgetSupportedProtocolsgetUseClientModegetWantClientAuthsetEnabledCipherSuitessetEnabledProtocolssetEnableSessionCreationsetHandshakeApplicationProtocolSelectorsetNeedClientAuthsetSSLParameterssetUseClientModesetWantClientAuthstartHandshake