Package org.conscrypt
Class OpenSSLSocketImpl
- java.lang.Object
-
- java.net.Socket
-
- javax.net.ssl.SSLSocket
-
- org.conscrypt.AbstractConscryptSocket
-
- org.conscrypt.OpenSSLSocketImpl
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
- Direct Known Subclasses:
ConscryptEngineSocket,ConscryptFileDescriptorSocket
@Internal public abstract class OpenSSLSocketImpl extends AbstractConscryptSocket
Public shim allowing us to stay backward-compatible with legacy applications which were using Conscrypt's extended socket API before the introduction of theConscryptclass.
-
-
Field Summary
-
Fields inherited from class org.conscrypt.AbstractConscryptSocket
socket
-
-
Constructor Summary
Constructors Constructor Description OpenSSLSocketImpl()OpenSSLSocketImpl(java.lang.String hostname, int port)OpenSSLSocketImpl(java.lang.String hostname, int port, java.net.InetAddress clientAddress, int clientPort)OpenSSLSocketImpl(java.net.InetAddress address, int port)OpenSSLSocketImpl(java.net.InetAddress address, int port, java.net.InetAddress clientAddress, int clientPort)OpenSSLSocketImpl(java.net.Socket socket, java.lang.String hostname, int port, boolean autoClose)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description byte[]getAlpnSelectedProtocol()Deprecated.useAbstractConscryptSocket.getApplicationProtocol()instead.abstract byte[]getChannelId()Gets the TLS Channel ID for this server socket.java.io.FileDescriptorgetFileDescriptor$()abstract javax.net.ssl.SSLSessiongetHandshakeSession()java.lang.StringgetHostname()Returns the hostname that was supplied during socket creation.java.lang.StringgetHostnameOrIP()For the purposes of an SSLSession, we want a way to represent the supplied hostname or the IP address in a textual representation.byte[]getNpnSelectedProtocol()Deprecated.NPN is not supportedintgetSoWriteTimeout()Note write timeouts are not part of the javax.net.ssl.SSLSocket APIvoidsetAlpnProtocols(byte[] protocols)Deprecated.UsesetAlpnProtocols(String[])instead.voidsetAlpnProtocols(java.lang.String[] alpnProtocols)Deprecated.abstract voidsetChannelIdEnabled(boolean enabled)Enables/disables TLS Channel ID for this server socket.abstract voidsetChannelIdPrivateKey(java.security.PrivateKey privateKey)Sets thePrivateKeyto be used for TLS Channel ID by this client socket.voidsetHandshakeTimeout(int handshakeTimeoutMilliseconds)Set the handshake timeout on this socket.voidsetHostname(java.lang.String hostname)This method enables Server Name IndicationvoidsetNpnProtocols(byte[] npnProtocols)Deprecated.NPN is not supportedvoidsetSoWriteTimeout(int writeTimeoutMilliseconds)Note write timeouts are not part of the javax.net.ssl.SSLSocket APIabstract voidsetUseSessionTickets(boolean useSessionTickets)This method enables session ticket support.-
Methods inherited from class org.conscrypt.AbstractConscryptSocket
addHandshakeCompletedListener, bind, checkOpen, close, connect, connect, exportKeyingMaterial, getActiveSession, getApplicationProtocol, getApplicationProtocols, getChannel, getHandshakeApplicationProtocol, getInetAddress, getInputStream, getKeepAlive, getLocalAddress, getLocalPort, getLocalSocketAddress, getOOBInline, getOutputStream, getPort, getReceiveBufferSize, getRemoteSocketAddress, getReuseAddress, getSendBufferSize, getSoLinger, getSoTimeout, getTcpNoDelay, getTlsUnique, getTrafficClass, isBound, isClosed, isConnected, isInputShutdown, isOutputShutdown, notifyHandshakeCompletedListeners, peerInfoProvider, removeHandshakeCompletedListener, sendUrgentData, setApplicationProtocols, setApplicationProtocolSelector, setApplicationProtocolSelector, setKeepAlive, setOOBInline, setPerformancePreferences, setReceiveBufferSize, setReuseAddress, setSendBufferSize, setSoLinger, setSoTimeout, setTcpNoDelay, setTrafficClass, shutdownInput, shutdownOutput, toString
-
Methods inherited from class javax.net.ssl.SSLSocket
getEnabledCipherSuites, getEnabledProtocols, getEnableSessionCreation, getHandshakeApplicationProtocolSelector, getNeedClientAuth, getSession, getSSLParameters, getSupportedCipherSuites, getSupportedProtocols, getUseClientMode, getWantClientAuth, setEnabledCipherSuites, setEnabledProtocols, setEnableSessionCreation, setHandshakeApplicationProtocolSelector, setNeedClientAuth, setSSLParameters, setUseClientMode, setWantClientAuth, startHandshake
-
-
-
-
Constructor Detail
-
OpenSSLSocketImpl
OpenSSLSocketImpl() throws java.io.IOException- Throws:
java.io.IOException
-
OpenSSLSocketImpl
OpenSSLSocketImpl(java.lang.String hostname, int port) throws java.io.IOException- Throws:
java.io.IOException
-
OpenSSLSocketImpl
OpenSSLSocketImpl(java.net.InetAddress address, int port) throws java.io.IOException- Throws:
java.io.IOException
-
OpenSSLSocketImpl
OpenSSLSocketImpl(java.lang.String hostname, int port, java.net.InetAddress clientAddress, int clientPort) throws java.io.IOException- Throws:
java.io.IOException
-
OpenSSLSocketImpl
OpenSSLSocketImpl(java.net.InetAddress address, int port, java.net.InetAddress clientAddress, int clientPort) throws java.io.IOException- Throws:
java.io.IOException
-
OpenSSLSocketImpl
OpenSSLSocketImpl(java.net.Socket socket, java.lang.String hostname, int port, boolean autoClose) throws java.io.IOException- Throws:
java.io.IOException
-
-
Method Detail
-
getHostname
public java.lang.String getHostname()
Description copied from class:AbstractConscryptSocketReturns the hostname that was supplied during socket creation. No DNS resolution is attempted before returning the hostname.- Overrides:
getHostnamein classAbstractConscryptSocket
-
setHostname
public void setHostname(java.lang.String hostname)
Description copied from class:AbstractConscryptSocketThis method enables Server Name Indication- Overrides:
setHostnamein classAbstractConscryptSocket- Parameters:
hostname- the desired SNI hostname, or null to disable
-
getHostnameOrIP
public java.lang.String getHostnameOrIP()
Description copied from class:AbstractConscryptSocketFor the purposes of an SSLSession, we want a way to represent the supplied hostname or the IP address in a textual representation. We do not want to perform reverse DNS lookups on this address.- Overrides:
getHostnameOrIPin classAbstractConscryptSocket
-
getFileDescriptor$
public java.io.FileDescriptor getFileDescriptor$()
- Overrides:
getFileDescriptor$in classAbstractConscryptSocket
-
setSoWriteTimeout
public void setSoWriteTimeout(int writeTimeoutMilliseconds) throws java.net.SocketExceptionDescription copied from class:AbstractConscryptSocketNote write timeouts are not part of the javax.net.ssl.SSLSocket API- Overrides:
setSoWriteTimeoutin classAbstractConscryptSocket- Throws:
java.net.SocketException
-
getSoWriteTimeout
public int getSoWriteTimeout() throws java.net.SocketExceptionDescription copied from class:AbstractConscryptSocketNote write timeouts are not part of the javax.net.ssl.SSLSocket API- Overrides:
getSoWriteTimeoutin classAbstractConscryptSocket- Throws:
java.net.SocketException
-
setHandshakeTimeout
public void setHandshakeTimeout(int handshakeTimeoutMilliseconds) throws java.net.SocketExceptionDescription copied from class:AbstractConscryptSocketSet the handshake timeout on this socket. This timeout is specified in milliseconds and will be used only during the handshake process.- Overrides:
setHandshakeTimeoutin classAbstractConscryptSocket- Throws:
java.net.SocketException
-
getHandshakeSession
public abstract javax.net.ssl.SSLSession getHandshakeSession()
- Specified by:
getHandshakeSessionin classAbstractConscryptSocket
-
setUseSessionTickets
public abstract void setUseSessionTickets(boolean useSessionTickets)
Description copied from class:AbstractConscryptSocketThis method enables session ticket support.- Specified by:
setUseSessionTicketsin classAbstractConscryptSocket- Parameters:
useSessionTickets- True to enable session tickets
-
setChannelIdEnabled
public abstract void setChannelIdEnabled(boolean enabled)
Description copied from class:AbstractConscryptSocketEnables/disables TLS Channel ID for this server socket.This method needs to be invoked before the handshake starts.
- Specified by:
setChannelIdEnabledin classAbstractConscryptSocket
-
getChannelId
public abstract byte[] getChannelId() throws javax.net.ssl.SSLExceptionDescription copied from class:AbstractConscryptSocketGets the TLS Channel ID for this server socket. Channel ID is only available once the handshake completes.- Specified by:
getChannelIdin classAbstractConscryptSocket- Returns:
- channel ID or
nullif not available. - Throws:
javax.net.ssl.SSLException- if channel ID is available but could not be obtained.
-
setChannelIdPrivateKey
public abstract void setChannelIdPrivateKey(java.security.PrivateKey privateKey)
Description copied from class:AbstractConscryptSocketSets thePrivateKeyto be used for TLS Channel ID by this client socket.This method needs to be invoked before the handshake starts.
- Specified by:
setChannelIdPrivateKeyin classAbstractConscryptSocket- Parameters:
privateKey- private key (enables TLS Channel ID) ornullfor 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).
-
getNpnSelectedProtocol
@Deprecated public final byte[] getNpnSelectedProtocol()
Deprecated.NPN is not supportedDescription copied from class:AbstractConscryptSocketReturns null always for backward compatibility.- Overrides:
getNpnSelectedProtocolin classAbstractConscryptSocket
-
setNpnProtocols
@Deprecated public final void setNpnProtocols(byte[] npnProtocols)
Deprecated.NPN is not supportedDescription copied from class:AbstractConscryptSocketThis method does nothing and is kept for backward compatibility.- Overrides:
setNpnProtocolsin classAbstractConscryptSocket
-
setAlpnProtocols
@Deprecated public final void setAlpnProtocols(java.lang.String[] alpnProtocols)
Deprecated.Description copied from class:AbstractConscryptSocketSets the list of ALPN protocols. This method internally converts the protocols to their wire-format form.- Specified by:
setAlpnProtocolsin classAbstractConscryptSocket- Parameters:
alpnProtocols- the list of ALPN protocols
-
getAlpnSelectedProtocol
@Deprecated public final byte[] getAlpnSelectedProtocol()
Deprecated.useAbstractConscryptSocket.getApplicationProtocol()instead.Description copied from class:AbstractConscryptSocketReturns the protocol agreed upon by client and server, ornullif no protocol was agreed upon.- Specified by:
getAlpnSelectedProtocolin classAbstractConscryptSocket
-
setAlpnProtocols
@Deprecated public final void setAlpnProtocols(byte[] protocols)
Deprecated.UsesetAlpnProtocols(String[])instead.Description copied from class:AbstractConscryptSocketAlternate version ofAbstractConscryptSocket.setAlpnProtocols(String[])that directly sets the list of ALPN in the wire-format form used by BoringSSL (length-prefixed 8-bit strings). Requires that all strings be encoded with US-ASCII.- Specified by:
setAlpnProtocolsin classAbstractConscryptSocket- Parameters:
protocols- the encoded form of the ALPN protocol list
-
-