Package org.mozilla.jss.ssl.javax
Class JSSSocket
java.lang.Object
java.net.Socket
javax.net.ssl.SSLSocket
org.mozilla.jss.ssl.SSLSocket
org.mozilla.jss.ssl.javax.JSSSocket
- All Implemented Interfaces:
Closeable,AutoCloseable
SSL-enabled socket following the javax.net.ssl.SSLSocket interface.
Most users will want to use the JSSSocketFactory provided by the Java
Provider interface instead of using this class directly.
This SSLSocket implementation is a wrapped implementation. In particular, we
need to consume an existing Socket (via the consumeSocket(...) call) which
we actually send data over. When called from a socket factory, this
additional socket will be automatically created for the caller. This
is necessary because SSLSocketFactory includes a mode which wraps an
existing socket.
All JSSSocket instances have a underlying SocketChannel, of type
JSSSocketChannel. Notably lacking is a javax.net.ssl.SSLSocketChannel type,
so JSSSocketChannel includes no additional SSL-specific options. However,
the core of the SSLEngine wrapping logic exists there.
In order to interoperate with JSSEngine, many of the adjacent methods have
been included in this class as well.
This socket can either be a client or a server, depending on how it was
created. For more information, see the javax.net.ssl.SSLSocket
documentation.
To construct a (useful) new instance, the following calls must be made:
- new JSSSocket();
- consumeSocket(inst);
- initSSLEngine(...);
- setKeyManagers(...);
- setTrustManagers(...);
Optionally, setSSLContext(...) could be called to provide the SSLContext
from which the SSLEngine should be constructed. This should be called prior
to initSSLEngine(...) being called.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanWhether or not to automatically close the underlying Socket when this socket has been closed; defaults to true.private JSSSocketChannelUnderlying SocketChannel for this socket; always exists.private booleanWhether or not this socket has been closed.private InputStreamPreviously consumed data, if any; utilized for certain SSLSocketFactory calls.private JSSEngineJSSEngine instance to utilize for SSLEngine operations.private StringName of the SSLEngine provider to use.private StringName of the SSLEngine protocol to use.private ArrayList<HandshakeCompletedListener>All registered handshake callbacks.private SSLContextSSLContext to use to create the JSSEngine.private SocketThe socket this JSSSocket was created over; all read/write operations go through this socket and all information exposed via Socket members go through here.Fields inherited from class org.mozilla.jss.ssl.SSLSocket
SSL_RENEGOTIATE_NEVER, SSL_RENEGOTIATE_REQUIRES_XTN, SSL_RENEGOTIATE_TRANSITIONAL, SSL_RENEGOTIATE_UNRESTRICTED, SSL_REQUIRE_ALWAYS, SSL_REQUIRE_FIRST_HANDSHAKE, SSL_REQUIRE_NEVER, SSL_REQUIRE_NO_ERROR, SSL_RSA_FIPS_WITH_3DES_EDE_CBC_SHA, SSL_RSA_FIPS_WITH_DES_CBC_SHA, SSL2_DES_192_EDE3_CBC_WITH_MD5, SSL2_DES_64_CBC_WITH_MD5, SSL2_IDEA_128_CBC_WITH_MD5, SSL2_RC2_128_CBC_EXPORT40_WITH_MD5, SSL2_RC2_128_CBC_WITH_MD5, SSL2_RC4_128_EXPORT40_WITH_MD5, SSL2_RC4_128_WITH_MD5, SSL3_DH_ANON_EXPORT_WITH_DES40_CBC_SHA, SSL3_DH_ANON_EXPORT_WITH_RC4_40_MD5, SSL3_DH_ANON_WITH_3DES_EDE_CBC_SHA, SSL3_DH_ANON_WITH_DES_CBC_SHA, SSL3_DH_ANON_WITH_RC4_128_MD5, SSL3_DH_DSS_EXPORT_WITH_DES40_CBC_SHA, SSL3_DH_DSS_WITH_3DES_EDE_CBC_SHA, SSL3_DH_DSS_WITH_DES_CBC_SHA, SSL3_DH_RSA_EXPORT_WITH_DES40_CBC_SHA, SSL3_DH_RSA_WITH_3DES_EDE_CBC_SHA, SSL3_DH_RSA_WITH_DES_CBC_SHA, SSL3_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA, SSL3_DHE_DSS_WITH_3DES_EDE_CBC_SHA, SSL3_DHE_DSS_WITH_DES_CBC_SHA, SSL3_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA, SSL3_DHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL3_DHE_RSA_WITH_DES_CBC_SHA, SSL3_FORTEZZA_DMS_WITH_FORTEZZA_CBC_SHA, SSL3_FORTEZZA_DMS_WITH_NULL_SHA, SSL3_FORTEZZA_DMS_WITH_RC4_128_SHA, SSL3_RSA_EXPORT_WITH_DES40_CBC_SHA, SSL3_RSA_EXPORT_WITH_RC2_CBC_40_MD5, SSL3_RSA_EXPORT_WITH_RC4_40_MD5, SSL3_RSA_WITH_3DES_EDE_CBC_SHA, SSL3_RSA_WITH_DES_CBC_SHA, SSL3_RSA_WITH_IDEA_CBC_SHA, SSL3_RSA_WITH_NULL_MD5, SSL3_RSA_WITH_NULL_SHA, SSL3_RSA_WITH_RC4_128_MD5, SSL3_RSA_WITH_RC4_128_SHA, TLS_AES_128_GCM_SHA256, TLS_AES_256_GCM_SHA384, TLS_CHACHA20_POLY1305_SHA256, TLS_DH_anon_EXPORT_WITH_DES40_CBC_SHA, TLS_DH_anon_EXPORT_WITH_RC4_40_MD5, TLS_DH_anon_WITH_3DES_EDE_CBC_SHA, TLS_DH_anon_WITH_AES_128_CBC_SHA, TLS_DH_ANON_WITH_AES_128_CBC_SHA, TLS_DH_anon_WITH_AES_256_CBC_SHA, TLS_DH_ANON_WITH_AES_256_CBC_SHA, TLS_DH_anon_WITH_CAMELLIA_128_CBC_SHA, TLS_DH_ANON_WITH_CAMELLIA_128_CBC_SHA, TLS_DH_anon_WITH_CAMELLIA_256_CBC_SHA, TLS_DH_ANON_WITH_CAMELLIA_256_CBC_SHA, TLS_DH_anon_WITH_DES_CBC_SHA, TLS_DH_anon_WITH_RC4_128_MD5, TLS_DH_DSS_EXPORT_WITH_DES40_CBC_SHA, TLS_DH_DSS_WITH_3DES_EDE_CBC_SHA, TLS_DH_DSS_WITH_AES_128_CBC_SHA, TLS_DH_DSS_WITH_AES_256_CBC_SHA, TLS_DH_DSS_WITH_CAMELLIA_128_CBC_SHA, TLS_DH_DSS_WITH_CAMELLIA_256_CBC_SHA, TLS_DH_DSS_WITH_DES_CBC_SHA, TLS_DH_RSA_EXPORT_WITH_DES40_CBC_SHA, TLS_DH_RSA_WITH_3DES_EDE_CBC_SHA, TLS_DH_RSA_WITH_AES_128_CBC_SHA, TLS_DH_RSA_WITH_AES_256_CBC_SHA, TLS_DH_RSA_WITH_CAMELLIA_128_CBC_SHA, TLS_DH_RSA_WITH_CAMELLIA_256_CBC_SHA, TLS_DH_RSA_WITH_DES_CBC_SHA, TLS_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA, TLS_DHE_DSS_EXPORT1024_WITH_DES_CBC_SHA, TLS_DHE_DSS_EXPORT1024_WITH_RC4_56_SHA, TLS_DHE_DSS_WITH_3DES_EDE_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA256, TLS_DHE_DSS_WITH_AES_128_GCM_SHA256, TLS_DHE_DSS_WITH_AES_256_CBC_SHA, TLS_DHE_DSS_WITH_AES_256_CBC_SHA256, TLS_DHE_DSS_WITH_AES_256_GCM_SHA384, TLS_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA, TLS_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA, TLS_DHE_DSS_WITH_DES_CBC_SHA, TLS_DHE_DSS_WITH_RC4_128_SHA, TLS_DHE_PSK_WITH_AES_128_GCM_SHA256, TLS_DHE_PSK_WITH_AES_256_GCM_SHA384, TLS_DHE_PSK_WITH_CHACHA20_POLY1305_SHA256, TLS_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA, TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA256, TLS_DHE_RSA_WITH_AES_128_GCM_SHA256, TLS_DHE_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_RSA_WITH_AES_256_CBC_SHA256, TLS_DHE_RSA_WITH_AES_256_GCM_SHA384, TLS_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA, TLS_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA, TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256, TLS_DHE_RSA_WITH_DES_CBC_SHA, TLS_ECDH_anon_WITH_3DES_EDE_CBC_SHA, TLS_ECDH_anon_WITH_AES_128_CBC_SHA, TLS_ECDH_anon_WITH_AES_256_CBC_SHA, TLS_ECDH_anon_WITH_NULL_SHA, TLS_ECDH_anon_WITH_RC4_128_SHA, TLS_ECDH_ECDSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDH_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDH_ECDSA_WITH_NULL_SHA, TLS_ECDH_ECDSA_WITH_RC4_128_SHA, TLS_ECDH_RSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDH_RSA_WITH_AES_128_CBC_SHA, TLS_ECDH_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDH_RSA_WITH_AES_256_CBC_SHA, TLS_ECDH_RSA_WITH_NULL_SHA, TLS_ECDH_RSA_WITH_RC4_128_SHA, TLS_ECDHE_ECDSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384, TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256, TLS_ECDHE_ECDSA_WITH_NULL_SHA, TLS_ECDHE_ECDSA_WITH_RC4_128_SHA, TLS_ECDHE_PSK_WITH_AES_128_GCM_SHA256, TLS_ECDHE_PSK_WITH_AES_256_GCM_SHA384, TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256, TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, TLS_ECDHE_RSA_WITH_NULL_SHA, TLS_ECDHE_RSA_WITH_RC4_128_SHA, TLS_EMPTY_RENEGOTIATION_INFO_SCSV, TLS_FALLBACK_SCSV, TLS_NULL_WITH_NULL_NULL, TLS_RSA_EXPORT_WITH_DES40_CBC_SHA, TLS_RSA_EXPORT_WITH_RC2_CBC_40_MD5, TLS_RSA_EXPORT_WITH_RC4_40_MD5, TLS_RSA_EXPORT1024_WITH_DES_CBC_SHA, TLS_RSA_EXPORT1024_WITH_RC4_56_SHA, TLS_RSA_WITH_3DES_EDE_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA256, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA256, TLS_RSA_WITH_AES_256_GCM_SHA384, TLS_RSA_WITH_CAMELLIA_128_CBC_SHA, TLS_RSA_WITH_CAMELLIA_256_CBC_SHA, TLS_RSA_WITH_DES_CBC_SHA, TLS_RSA_WITH_IDEA_CBC_SHA, TLS_RSA_WITH_NULL_MD5, TLS_RSA_WITH_NULL_SHA, TLS_RSA_WITH_NULL_SHA256, TLS_RSA_WITH_RC4_128_MD5, TLS_RSA_WITH_RC4_128_SHA, TLS_RSA_WITH_SEED_CBC_SHA -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a callback to fire on handshake completion.voidbind(SocketAddress bindpoint) voidclose()Closes this socket.voidconnect(SocketAddress endpoint) voidconnect(SocketAddress endpoint, int timeout) voidconsumeSocket(Socket parent) Consume a parent socket, utilizing it for all read/write operations.private voidInternal helper to perform the handshake operation, blocking.booleanGet the autoClose status of this socket, that is, whether or not its parent socket will be automatically closed.Get the underlying SocketChannel for this Socket.String[]Get the set of enabled cipher suites for this SSLSocket.String[]Get the set of enabled protocol versions for this SSLSocket.booleanGet whether or not this SSLSocket enables creation of new sessions.Get the underlying JSSEngine instance.Get the initial session constructed during handshaking.Get a copy of an input stream for this Socket.protected JSSSocketChannelHelper to always return the channel for this socket, initializing it if it isn't yet created.booleanReturns the current setting of the SO_KEEPALIVE socket option.Collection<? extends EventListener>Gets the current list of event listeners this SSLSocket will fire on certain events.intbooleanGet whether or not this SSLSocket needs client authentication.boolean<T> TgetOption(SocketOption<T> name) Get a copy of an output stream for this Socket.intgetPort()intReturns the size (in bytes) of the receive buffer.booleanintReturns the size (in bytes) of the send buffer.Get the established session for this SSLSocket.intReturns the current value of the SO_LINGER socket option.intReturns the current value of the SO_TIMEOUT socket option.protected SSLContextGet the SSLContext if one exists or create a new instance.Get the configuration of this SSLSocket as a JSSParameters object.String[]Get the set of supported cipher suites for this SSLSocket.String[]Get the set of supported protocol versions for this SSLSocket.booleanReturns the current setting of the TCP_NO_DELAY socket option.intbooleanGet whether or not this SSLSocket is handshaking as a client.booleanGet whether or not this SSLSocket wants client authentication.private voidinit()Initialize the underlying SocketChannel.voidExplicitly initialize the SSLEngine with no session resumption information.voidinitEngine(String host, int port) Explicitly initialize the SSLEngine with information for session resumption, including peer's hostname and port.booleanisBound()booleanisClosed()booleanbooleanbooleanprotected voidInternal helper to fire callbacks on handshake completion.voidRemove a callback from firing on handshake completion.voidsendUrgentData(int data) voidsetAutoClose(boolean on) Set the autoClose status of this socket, that is, whether or not its parent socket will be automatically closed.voidsetCertFromAlias(String alias) Set the certificate this SSLSocket will utilize from an alias in the NSS DB.voidsetConsumedData(InputStream consumed) Helper to inform this socket of data already consumed from the wrapped socket.voidsetEnabledCipherSuites(String[] suites) Set the list of enabled cipher suites for this SSLSocket.voidsetEnabledProtocols(String[] protocols) Set the list of enabled protocol versions for this SSLSocket.voidsetEnableSessionCreation(boolean enabled) Set whether or not this SSLSocket enables creation of new sessions.voidsetHostname(String name) Set the hostname this client socket is connecting to, for HTTPS TLS certificate validation purposes.voidsetKeepAlive(boolean on) Enables or disables the SO_KEEPALIVE socket option.voidSet the KeyManager this SSLSocket will utilize to select a key.voidsetKeyManagers(X509KeyManager[] xkms) Set the key managers this SSLSocket will utilize to select a key.voidsetKeyMaterials(PK11Cert ourCert, PK11PrivKey ourKey) Set the certificate this SSLSocket will utilize from a certificate and its matching private key.voidsetListeners(Collection<? extends EventListener> listeners) Set the listeners this SSLSocket will fire on certain events.voidsetNeedClientAuth(boolean need) Set whether or not this SSLSocket needs client authentication.voidsetOOBInline(boolean on) <T> SocketsetOption(SocketOption<T> name, T value) voidsetPerformancePreferences(int connectionTime, int latency, int bandwidth) voidsetReceiveBufferSize(int size) Sets the size (in bytes) of the receive buffer.voidsetReuseAddress(boolean on) voidsetSendBufferSize(int size) Sets the size (in bytes) of the send buffer.voidsetSoLinger(boolean on, int linger) Sets the SO_LINGER socket option.voidsetSoTimeout(int timeout) Sets the SO_TIMEOUT socket option.voidsetSSLContext(SSLContext ctx) Explicitly set the SSLContext utilized by this JSSSocket instance.voidsetSSLParameters(SSLParameters params) Set the configuration of this SSLSocket from the given SSLParameters instance.voidsetTcpNoDelay(boolean on) Enables or disables the TCP_NO_DELAY socket option.voidsetTrafficClass(int tc) voidSet the trust manager this SSLSocket will utilize to validate a peer's certificate.voidsetTrustManagers(X509TrustManager[] xtms) Set the trust managers this SSLSocket will utilize to validate a peer's certificate.voidsetUseClientMode(boolean client) Set whether or not this SSLSocket is handshaking as a client.voidsetWantClientAuth(boolean want) Set whether or not this SSLSocket wants client authentication.voidShuts down the input side of the socket.voidShuts down the output side of the socket.voidBegin a handshake, blocking to completion; this will begin a new handshake when one has already been issued.Set<SocketOption<?>>toString()Returns the addresses and ports of this socket or an error message if the socket is not in a valid state.Methods inherited from class org.mozilla.jss.ssl.SSLSocket
addHandshakeCompletedListener, addSocketListener, boundSSLVersionRange, enableFDX, enablePostHandshakeAuth, enablePostHandshakeAuthDefault, enableRenegotiation, enableRenegotiationDefault, enableRequireSafeNegotiation, enableRequireSafeNegotiationDefault, enableRollbackDetection, enableSessionTickets, enableSessionTicketsDefault, enableSSL2, enableSSL2Default, enableSSL3, enableSSL3Default, enableStepDown, enableTLS, enableTLSDefault, enableV2CompatibleHello, finalize, forceHandshake, getCipherPreference, getCipherPreferenceDefault, getImplementedCipherSuites, getSSLDefaultOptions, getSSLOptions, getStatus, invalidateSession, isFipsCipherSuite, redoHandshake, redoHandshake, removeHandshakeCompletedListener, removeSocketListener, requestClientAuth, requireClientAuth, requireClientAuth, requireClientAuthDefault, requireClientAuthDefault, resetHandshake, setCipherPolicy, setCipherPreference, setCipherPreferenceDefault, setClientCert, setClientCertNickname, setNeedClientAuthNoExpiryCheck, setSSLVersionRangeDefault, useCache, useCacheDefaultMethods inherited from class javax.net.ssl.SSLSocket
getApplicationProtocol, getHandshakeApplicationProtocol, getHandshakeApplicationProtocolSelector, setHandshakeApplicationProtocolSelectorMethods inherited from class java.net.Socket
setSocketImplFactory
-
Field Details
-
engineProviderProtocol
Name of the SSLEngine protocol to use. -
engineProvider
Name of the SSLEngine provider to use. -
jssContext
SSLContext to use to create the JSSEngine. Note that JSSSocket will fail if the context doesn't create JSSEngine instances. -
engine
JSSEngine instance to utilize for SSLEngine operations. -
handshakeCallbacks
All registered handshake callbacks. -
parent
The socket this JSSSocket was created over; all read/write operations go through this socket and all information exposed via Socket members go through here. -
consumedData
Previously consumed data, if any; utilized for certain SSLSocketFactory calls. -
channel
Underlying SocketChannel for this socket; always exists. -
autoClose
private boolean autoCloseWhether or not to automatically close the underlying Socket when this socket has been closed; defaults to true. -
closed
private boolean closedWhether or not this socket has been closed.
-
-
Constructor Details
-
JSSSocket
public JSSSocket()Start building a new JSSSocket. We specifically avoid creating any other constructors as we wish to consume an existing socket rather than creating a new one.
-
-
Method Details
-
consumeSocket
Consume a parent socket, utilizing it for all read/write operations. This JSSSocket instance will inherit all information about the connection from this underlying socket. When utilized in a JSSSocket, callers should refrain from interacting with the underlying socket directly until the TLS connection is closed. Otherwise, messages may get dropped.- Throws:
IOException
-
getSSLContext
Get the SSLContext if one exists or create a new instance. This is used by initSSLEngine(..) to create the underlying SSLEngine.- Throws:
IOException
-
setSSLContext
Explicitly set the SSLContext utilized by this JSSSocket instance. This enables JSSServerSocket to copy its SSLContext over to the accepted JSSSocket. -
init
Initialize the underlying SocketChannel.- Throws:
IOException
-
initEngine
Explicitly initialize the SSLEngine with no session resumption information.- Throws:
IOException
-
initEngine
Explicitly initialize the SSLEngine with information for session resumption, including peer's hostname and port.- Throws:
IOException
-
getEngine
Get the underlying JSSEngine instance. Note that, just like accessing the underlying Socket instance while the JSSSocket instance is still open is dangerous, performing other TLS operations directly via JSSEngine is also dangerous. This is mostly exposed to enable advanced configuration of the JSSEngine that isn't otherwise allowed by JSSSocket, and to facilitate the accept() method on JSSServerSocket. -
getChannel
Get the underlying SocketChannel for this Socket.- Overrides:
getChannelin classSocket- See Also:
-
getInternalChannel
Helper to always return the channel for this socket, initializing it if it isn't yet created. -
getInputStream
Get a copy of an input stream for this Socket.- Overrides:
getInputStreamin classSSLSocket- Throws:
IOException- See Also:
-
getOutputStream
Get a copy of an output stream for this Socket.- Overrides:
getOutputStreamin classSSLSocket- Throws:
IOException- See Also:
-
doHandshake
Internal helper to perform the handshake operation, blocking. Note that JSSSocket doesn't invoke JSSEngine.wrap/unwrap directly; instead everything is contained within JSSSocketChannel.- Throws:
IOException
-
setConsumedData
Helper to inform this socket of data already consumed from the wrapped socket. This is provided to facilitate a SSLSocketFactory call which allows construction of SSLSocket instances from a non-SSL ServerSocket, allowing the application to check SNI information directly. -
getAutoClose
public boolean getAutoClose()Get the autoClose status of this socket, that is, whether or not its parent socket will be automatically closed. -
setAutoClose
public void setAutoClose(boolean on) Set the autoClose status of this socket, that is, whether or not its parent socket will be automatically closed. -
setHostname
Set the hostname this client socket is connecting to, for HTTPS TLS certificate validation purposes.- See Also:
-
setCertFromAlias
Set the certificate this SSLSocket will utilize from an alias in the NSS DB.- Throws:
IllegalArgumentException- See Also:
-
setKeyMaterials
Set the certificate this SSLSocket will utilize from a certificate and its matching private key.- Throws:
IllegalArgumentException- See Also:
-
setKeyManager
Set the KeyManager this SSLSocket will utilize to select a key.- See Also:
-
setKeyManagers
Set the key managers this SSLSocket will utilize to select a key. -
setTrustManager
Set the trust manager this SSLSocket will utilize to validate a peer's certificate. -
setTrustManagers
Set the trust managers this SSLSocket will utilize to validate a peer's certificate. -
setListeners
Set the listeners this SSLSocket will fire on certain events.- See Also:
-
getListeners
Gets the current list of event listeners this SSLSocket will fire on certain events.- See Also:
-
startHandshake
Begin a handshake, blocking to completion; this will begin a new handshake when one has already been issued.- Overrides:
startHandshakein classSSLSocket- Throws:
IOException- See Also:
-
addHandshakeCompletedListener
public void addHandshakeCompletedListener(HandshakeCompletedListener callback) throws IllegalArgumentException Add a callback to fire on handshake completion.- Overrides:
addHandshakeCompletedListenerin classSSLSocket- Throws:
IllegalArgumentException- See Also:
-
notifyHandshakeCompletedListeners
protected void notifyHandshakeCompletedListeners()Internal helper to fire callbacks on handshake completion. -
removeHandshakeCompletedListener
public void removeHandshakeCompletedListener(HandshakeCompletedListener callback) throws IllegalArgumentException Remove a callback from firing on handshake completion.- Overrides:
removeHandshakeCompletedListenerin classSSLSocket- Throws:
IllegalArgumentException- See Also:
-
getEnabledCipherSuites
Get the set of enabled cipher suites for this SSLSocket.- Overrides:
getEnabledCipherSuitesin classSSLSocket- See Also:
-
getSupportedCipherSuites
Get the set of supported cipher suites for this SSLSocket.- Overrides:
getSupportedCipherSuitesin classSSLSocket- See Also:
-
setEnabledCipherSuites
Set the list of enabled cipher suites for this SSLSocket.- Overrides:
setEnabledCipherSuitesin classSSLSocket- See Also:
-
getEnabledProtocols
Get the set of enabled protocol versions for this SSLSocket.- Overrides:
getEnabledProtocolsin classSSLSocket- See Also:
-
getSupportedProtocols
Get the set of supported protocol versions for this SSLSocket.- Overrides:
getSupportedProtocolsin classSSLSocket- See Also:
-
setEnabledProtocols
Set the list of enabled protocol versions for this SSLSocket.- Overrides:
setEnabledProtocolsin classSSLSocket- See Also:
-
getEnableSessionCreation
public boolean getEnableSessionCreation()Get whether or not this SSLSocket enables creation of new sessions.- Overrides:
getEnableSessionCreationin classSSLSocket- See Also:
-
setEnableSessionCreation
public void setEnableSessionCreation(boolean enabled) Set whether or not this SSLSocket enables creation of new sessions.- Overrides:
setEnableSessionCreationin classSSLSocket- See Also:
-
getHandshakeSession
Get the initial session constructed during handshaking.- Overrides:
getHandshakeSessionin classSSLSocket- See Also:
-
getSession
Get the established session for this SSLSocket.- Overrides:
getSessionin classSSLSocket- See Also:
-
getUseClientMode
public boolean getUseClientMode()Get whether or not this SSLSocket is handshaking as a client.- Overrides:
getUseClientModein classSSLSocket- Returns:
- true if this end of the socket is the SSL client, false if it is the SSL server.
- See Also:
-
setUseClientMode
public void setUseClientMode(boolean client) Set whether or not this SSLSocket is handshaking as a client.- Overrides:
setUseClientModein classSSLSocket- Parameters:
client- true if this end of the socket is the SSL slient, false if it is the SSL server.- See Also:
-
getWantClientAuth
public boolean getWantClientAuth()Get whether or not this SSLSocket wants client authentication.- Overrides:
getWantClientAuthin classSSLSocket- See Also:
-
setWantClientAuth
public void setWantClientAuth(boolean want) Set whether or not this SSLSocket wants client authentication.- Overrides:
setWantClientAuthin classSSLSocket- See Also:
-
getNeedClientAuth
public boolean getNeedClientAuth()Get whether or not this SSLSocket needs client authentication.- Overrides:
getNeedClientAuthin classSSLSocket- See Also:
-
setNeedClientAuth
public void setNeedClientAuth(boolean need) Set whether or not this SSLSocket needs client authentication.- Overrides:
setNeedClientAuthin classSSLSocket- See Also:
-
getSSLParameters
Get the configuration of this SSLSocket as a JSSParameters object.- Overrides:
getSSLParametersin classSSLSocket- See Also:
-
setSSLParameters
Set the configuration of this SSLSocket from the given SSLParameters instance.- Overrides:
setSSLParametersin classSSLSocket- See Also:
-
connect
- Overrides:
connectin classSocket- Throws:
IOException
-
connect
- Overrides:
connectin classSocket- Throws:
IOException
-
bind
- Overrides:
bindin classSocket- Throws:
IOException
-
close
Description copied from class:SSLSocketCloses this socket.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classSSLSocket- Throws:
IOException
-
shutdownInput
Description copied from class:SSLSocketShuts down the input side of the socket.- Overrides:
shutdownInputin classSSLSocket- Throws:
IOException
-
shutdownOutput
Description copied from class:SSLSocketShuts down the output side of the socket.- Overrides:
shutdownOutputin classSSLSocket- Throws:
IOException
-
getInetAddress
- Overrides:
getInetAddressin classSSLSocket- Returns:
- The remote peer's IP address or null if the SSLSocket is closed.
-
getLocalAddress
- Overrides:
getLocalAddressin classSSLSocket- Returns:
- The local IP address or null if the SSLSocket is closed.
-
getPort
public int getPort() -
getLocalPort
public int getLocalPort()- Overrides:
getLocalPortin classSSLSocket- Returns:
- The local port or -1 if the SSLSocket is closed.
-
getLocalSocketAddress
- Overrides:
getLocalSocketAddressin classSocket
-
getRemoteSocketAddress
- Overrides:
getRemoteSocketAddressin classSocket
-
getTcpNoDelay
Description copied from class:SSLSocketReturns the current setting of the TCP_NO_DELAY socket option.- Overrides:
getTcpNoDelayin classSSLSocket- Throws:
SocketException
-
setTcpNoDelay
Description copied from class:SSLSocketEnables or disables the TCP_NO_DELAY socket option. Enabling this option will disable the Nagle algorithm.- Overrides:
setTcpNoDelayin classSSLSocket- Throws:
SocketException
-
getSoLinger
Description copied from class:SSLSocketReturns the current value of the SO_LINGER socket option.- Overrides:
getSoLingerin classSSLSocket- Throws:
SocketException
-
setSoLinger
Description copied from class:SSLSocketSets the SO_LINGER socket option. param linger The time (in seconds) to linger for.- Overrides:
setSoLingerin classSSLSocket- Throws:
SocketException
-
getSoTimeout
Description copied from class:SSLSocketReturns the current value of the SO_TIMEOUT socket option.- Overrides:
getSoTimeoutin classSSLSocket- Returns:
- The timeout time in milliseconds.
- Throws:
SocketException
-
setSoTimeout
Description copied from class:SSLSocketSets the SO_TIMEOUT socket option.- Overrides:
setSoTimeoutin classSSLSocket- Parameters:
timeout- The timeout time in milliseconds.- Throws:
SocketException
-
getOOBInline
- Overrides:
getOOBInlinein classSocket- Throws:
SocketException
-
setOOBInline
- Overrides:
setOOBInlinein classSocket- Throws:
SocketException
-
sendUrgentData
- Overrides:
sendUrgentDatain classSocket- Throws:
IOException
-
getSendBufferSize
Description copied from class:SSLSocketReturns the size (in bytes) of the send buffer.- Overrides:
getSendBufferSizein classSSLSocket- Throws:
SocketException
-
setSendBufferSize
Description copied from class:SSLSocketSets the size (in bytes) of the send buffer.- Overrides:
setSendBufferSizein classSSLSocket- Throws:
SocketException
-
getReceiveBufferSize
Description copied from class:SSLSocketReturns the size (in bytes) of the receive buffer.- Overrides:
getReceiveBufferSizein classSSLSocket- Throws:
SocketException
-
setReceiveBufferSize
Description copied from class:SSLSocketSets the size (in bytes) of the receive buffer.- Overrides:
setReceiveBufferSizein classSSLSocket- Throws:
SocketException
-
getKeepAlive
Description copied from class:SSLSocketReturns the current setting of the SO_KEEPALIVE socket option.- Overrides:
getKeepAlivein classSSLSocket- Throws:
SocketException
-
setKeepAlive
Description copied from class:SSLSocketEnables or disables the SO_KEEPALIVE socket option.- Overrides:
setKeepAlivein classSSLSocket- Throws:
SocketException
-
getTrafficClass
- Overrides:
getTrafficClassin classSocket- Throws:
SocketException
-
setTrafficClass
- Overrides:
setTrafficClassin classSocket- Throws:
SocketException
-
getReuseAddress
- Overrides:
getReuseAddressin classSocket- Throws:
SocketException
-
setReuseAddress
- Overrides:
setReuseAddressin classSocket- Throws:
SocketException
-
isConnected
public boolean isConnected()- Overrides:
isConnectedin classSocket
-
isBound
public boolean isBound() -
isClosed
public boolean isClosed() -
isInputShutdown
public boolean isInputShutdown()- Overrides:
isInputShutdownin classSocket
-
isOutputShutdown
public boolean isOutputShutdown()- Overrides:
isOutputShutdownin classSocket
-
setPerformancePreferences
public void setPerformancePreferences(int connectionTime, int latency, int bandwidth) - Overrides:
setPerformancePreferencesin classSocket
-
toString
Description copied from class:SSLSocketReturns the addresses and ports of this socket or an error message if the socket is not in a valid state. -
setOption
- Overrides:
setOptionin classSocket- Throws:
IOException
-
getOption
- Overrides:
getOptionin classSocket- Throws:
IOException
-
supportedOptions
- Overrides:
supportedOptionsin classSocket
-