public final class OpenSSLEngineSocketImpl extends OpenSSLSocketImplWrapper
Constructor and Description |
---|
OpenSSLEngineSocketImpl(Socket socket,
String hostname,
int port,
boolean autoClose,
SSLParametersImpl sslParameters) |
Modifier and Type | Method and Description |
---|---|
String |
chooseClientAlias(X509KeyManager keyManager,
X500Principal[] issuers,
String[] keyTypes) |
String |
chooseClientPSKIdentity(PSKKeyManager keyManager,
String identityHint) |
String |
chooseServerAlias(X509KeyManager keyManager,
String keyType) |
String |
chooseServerPSKIdentityHint(PSKKeyManager keyManager) |
void |
close() |
protected void |
finalize() |
byte[] |
getAlpnSelectedProtocol()
Returns the protocol agreed upon by client and server, or
null if
no protocol was agreed upon. |
SocketChannel |
getChannel() |
byte[] |
getChannelId()
Gets the TLS Channel ID for this server socket.
|
String[] |
getEnabledCipherSuites() |
String[] |
getEnabledProtocols() |
boolean |
getEnableSessionCreation() |
FileDescriptor |
getFileDescriptor$() |
InputStream |
getInputStream() |
boolean |
getNeedClientAuth() |
byte[] |
getNpnSelectedProtocol()
Returns null always for backward compatibility.
|
OutputStream |
getOutputStream() |
SecretKey |
getPSKKey(PSKKeyManager keyManager,
String identityHint,
String identity) |
SSLSession |
getSession() |
int |
getSoWriteTimeout()
Note write timeouts are not part of the javax.net.ssl.SSLSocket API
|
String[] |
getSupportedCipherSuites() |
String[] |
getSupportedProtocols() |
boolean |
getUseClientMode() |
boolean |
getWantClientAuth() |
void |
onSSLStateChange(int type,
int val)
Called when SSL state changes.
|
void |
sendUrgentData(int data) |
void |
setAlpnProtocols(byte[] alpnProtocols)
Sets the list of protocols this peer is interested in.
|
void |
setChannelIdEnabled(boolean enabled)
Enables/disables TLS Channel ID for this server socket.
|
void |
setChannelIdPrivateKey(PrivateKey privateKey)
Sets the
PrivateKey to be used for TLS Channel ID by this client socket. |
void |
setEnabledCipherSuites(String[] suites) |
void |
setEnabledProtocols(String[] protocols) |
void |
setEnableSessionCreation(boolean flag) |
void |
setHandshakeTimeout(int handshakeTimeoutMilliseconds)
Set the handshake timeout on this socket.
|
void |
setHostname(String hostname)
This method enables Server Name Indication
|
void |
setNeedClientAuth(boolean need) |
void |
setNpnProtocols(byte[] npnProtocols)
This method does nothing and is kept for backward compatibility.
|
void |
setOOBInline(boolean on) |
void |
setSoWriteTimeout(int writeTimeoutMilliseconds)
Note write timeouts are not part of the javax.net.ssl.SSLSocket API
|
void |
setUseClientMode(boolean mode) |
void |
setUseSessionTickets(boolean useSessionTickets)
This method enables session ticket support.
|
void |
setWantClientAuth(boolean want) |
void |
startHandshake()
Starts a TLS/SSL handshake on this connection using some native methods
from the OpenSSL library.
|
void |
verifyCertificateChain(long[] certRefs,
String authMethod)
Verify that we trust the certificate chain is trusted.
|
bind, connect, connect, getInetAddress, getKeepAlive, getLocalAddress, getLocalPort, getLocalSocketAddress, getOOBInline, getPort, getReceiveBufferSize, getRemoteSocketAddress, getReuseAddress, getSendBufferSize, getSoLinger, getSoTimeout, getTcpNoDelay, getTrafficClass, isBound, isClosed, isConnected, isInputShutdown, isOutputShutdown, setKeepAlive, setReceiveBufferSize, setReuseAddress, setSendBufferSize, setSoLinger, setTcpNoDelay, setTrafficClass, toString
addHandshakeCompletedListener, clientCertificateRequested, clientPSKKeyRequested, getHandshakeSession, getHostname, getHostnameOrIP, getSSLParameters, removeHandshakeCompletedListener, serverPSKKeyRequested, setSoTimeout, setSSLParameters
setPerformancePreferences, setSocketImplFactory, shutdownInput, shutdownOutput
public OpenSSLEngineSocketImpl(Socket socket, String hostname, int port, boolean autoClose, SSLParametersImpl sslParameters) throws IOException
IOException
public void startHandshake() throws IOException
OpenSSLSocketImpl
startHandshake
in class OpenSSLSocketImpl
IOException
public void onSSLStateChange(int type, int val)
NativeCrypto.SSLHandshakeCallbacks
onSSLStateChange
in interface NativeCrypto.SSLHandshakeCallbacks
onSSLStateChange
in class OpenSSLSocketImpl
public void verifyCertificateChain(long[] certRefs, String authMethod) throws CertificateException
NativeCrypto.SSLHandshakeCallbacks
verifyCertificateChain
in interface NativeCrypto.SSLHandshakeCallbacks
verifyCertificateChain
in class OpenSSLSocketImpl
certRefs
- chain of X.509 certificate referencesauthMethod
- auth algorithm nameCertificateException
- if the certificate is untrustedpublic InputStream getInputStream() throws IOException
getInputStream
in class OpenSSLSocketImpl
IOException
public OutputStream getOutputStream() throws IOException
getOutputStream
in class OpenSSLSocketImpl
IOException
public SSLSession getSession()
getSession
in class OpenSSLSocketImpl
public boolean getEnableSessionCreation()
getEnableSessionCreation
in class OpenSSLSocketImpl
public void setEnableSessionCreation(boolean flag)
setEnableSessionCreation
in class OpenSSLSocketImpl
public String[] getSupportedCipherSuites()
getSupportedCipherSuites
in class OpenSSLSocketImpl
public String[] getEnabledCipherSuites()
getEnabledCipherSuites
in class OpenSSLSocketImpl
public void setEnabledCipherSuites(String[] suites)
setEnabledCipherSuites
in class OpenSSLSocketImpl
public String[] getSupportedProtocols()
getSupportedProtocols
in class OpenSSLSocketImpl
public String[] getEnabledProtocols()
getEnabledProtocols
in class OpenSSLSocketImpl
public void setEnabledProtocols(String[] protocols)
setEnabledProtocols
in class OpenSSLSocketImpl
public void setUseSessionTickets(boolean useSessionTickets)
OpenSSLSocketImpl
setUseSessionTickets
in class OpenSSLSocketImpl
useSessionTickets
- True to enable session ticketspublic void setHostname(String hostname)
OpenSSLSocketImpl
setHostname
in class OpenSSLSocketImpl
hostname
- the desired SNI hostname, or null to disablepublic void setChannelIdEnabled(boolean enabled)
OpenSSLSocketImpl
This method needs to be invoked before the handshake starts.
setChannelIdEnabled
in class OpenSSLSocketImpl
public byte[] getChannelId() throws SSLException
OpenSSLSocketImpl
getChannelId
in class OpenSSLSocketImpl
null
if not available.SSLException
- if channel ID is available but could not be obtained.public void setChannelIdPrivateKey(PrivateKey privateKey)
OpenSSLSocketImpl
PrivateKey
to be used for TLS Channel ID by this client socket.
This method needs to be invoked before the handshake starts.
setChannelIdPrivateKey
in class OpenSSLSocketImpl
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).public boolean getUseClientMode()
getUseClientMode
in class OpenSSLSocketImpl
public void setUseClientMode(boolean mode)
setUseClientMode
in class OpenSSLSocketImpl
public boolean getWantClientAuth()
getWantClientAuth
in class OpenSSLSocketImpl
public boolean getNeedClientAuth()
getNeedClientAuth
in class OpenSSLSocketImpl
public void setNeedClientAuth(boolean need)
setNeedClientAuth
in class OpenSSLSocketImpl
public void setWantClientAuth(boolean want)
setWantClientAuth
in class OpenSSLSocketImpl
public void sendUrgentData(int data) throws IOException
sendUrgentData
in class OpenSSLSocketImpl
IOException
public void setOOBInline(boolean on) throws SocketException
setOOBInline
in class OpenSSLSocketImpl
SocketException
public void setSoWriteTimeout(int writeTimeoutMilliseconds) throws SocketException
OpenSSLSocketImpl
setSoWriteTimeout
in class OpenSSLSocketImpl
SocketException
public int getSoWriteTimeout() throws SocketException
OpenSSLSocketImpl
getSoWriteTimeout
in class OpenSSLSocketImpl
SocketException
public void setHandshakeTimeout(int handshakeTimeoutMilliseconds) throws SocketException
OpenSSLSocketImpl
setHandshakeTimeout
in class OpenSSLSocketImpl
SocketException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class OpenSSLSocketImpl
IOException
protected void finalize() throws Throwable
finalize
in class OpenSSLSocketImpl
Throwable
public SocketChannel getChannel()
getChannel
in class Socket
public FileDescriptor getFileDescriptor$()
getFileDescriptor$
in class OpenSSLSocketImpl
public byte[] getNpnSelectedProtocol()
OpenSSLSocketImpl
getNpnSelectedProtocol
in class OpenSSLSocketImpl
public byte[] getAlpnSelectedProtocol()
OpenSSLSocketImpl
null
if
no protocol was agreed upon.getAlpnSelectedProtocol
in class OpenSSLSocketImpl
public void setNpnProtocols(byte[] npnProtocols)
OpenSSLSocketImpl
setNpnProtocols
in class OpenSSLSocketImpl
public void setAlpnProtocols(byte[] alpnProtocols)
OpenSSLSocketImpl
null
, no protocols will be used.setAlpnProtocols
in class OpenSSLSocketImpl
alpnProtocols
- a non-empty array of protocol names. From
SSL_select_next_proto, "vector of 8-bit, length prefixed byte
strings. The length byte itself is not included in the length.
A byte string of length 0 is invalid. No byte string may be
truncated.".public String chooseServerAlias(X509KeyManager keyManager, String keyType)
chooseServerAlias
in interface SSLParametersImpl.AliasChooser
chooseServerAlias
in class OpenSSLSocketImpl
public String chooseClientAlias(X509KeyManager keyManager, X500Principal[] issuers, String[] keyTypes)
chooseClientAlias
in interface SSLParametersImpl.AliasChooser
chooseClientAlias
in class OpenSSLSocketImpl
public String chooseServerPSKIdentityHint(PSKKeyManager keyManager)
chooseServerPSKIdentityHint
in interface SSLParametersImpl.PSKCallbacks
chooseServerPSKIdentityHint
in class OpenSSLSocketImpl
public String chooseClientPSKIdentity(PSKKeyManager keyManager, String identityHint)
chooseClientPSKIdentity
in interface SSLParametersImpl.PSKCallbacks
chooseClientPSKIdentity
in class OpenSSLSocketImpl
public SecretKey getPSKKey(PSKKeyManager keyManager, String identityHint, String identity)
getPSKKey
in interface SSLParametersImpl.PSKCallbacks
getPSKKey
in class OpenSSLSocketImpl