public class EncryptedSocket
extends java.lang.Object
TCPSocket| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_HANDSHAKE_TIMEOUT_MILLIS
The default SSL/TLS handshake timeout in milliseconds = 8000.
|
static int |
DEFAULT_TCP_CONNECT_TIMEOUT_MILLIS
The default TCP connect timeout in milliseconds = 10000.
|
| Constructor and Description |
|---|
EncryptedSocket(java.lang.String serverHost,
int serverPort)
Create a new instance with an unconnected socket.
|
EncryptedSocket(java.lang.String severIpAddress,
java.lang.String serverHost,
int serverPort)
Create a new instance with an unconnected socket.
|
| Modifier and Type | Method and Description |
|---|---|
javax.net.ssl.SSLSocket |
connect()
Connect the socket to the server and perform the SSL/TLS handshake.
|
long |
getSSLHandshakeTime()
Get the time elapsed to perform the SSL/TLS handshake with the server (after the TCP/IP connection was established).
|
long |
getSSLPrepareTime()
Get the time elapsed to prepare (initialize) the SSL/TLS protocol at client side, before the TCP/IP connection is opened to the server.
|
long |
getTCPConnectTime()
Get the TCP/IP connect time for opening the network connection to the server.
|
void |
setClientAuthKeyManagers(javax.net.ssl.KeyManager[] clientAuthKeyManagers)
Set key managers for client authentication, for example extracted from a X509 client certificate.
|
void |
setHandshakeCompletedListener(javax.net.ssl.HandshakeCompletedListener handshakeCompletedListener)
Register an event listener to receive notifications that an SSL handshake has completed on this connection.
|
void |
setLimitSSLVersion(java.lang.String limitSSLVersion)
Set/limit the maximal used SSL version.
|
void |
setLocalOutboundAddress(java.net.InetAddress localOutboundAddress)
Set a specific outbound IP address.
|
void |
setSSLHandshakeTimeoutMillis(int sslHandshakeTimeoutMillis)
Set the SSL handshake timeout.
|
void |
setTCPConnectTimeoutMillis(int tcpConnectTimeoutMillis)
Set the TCP connect timeout.
|
void |
setTrustManager(javax.net.ssl.TrustManager[] trustManagers)
Set a specific X509 trust manager to validate certificate chains received from the server during the SSL handshake.
|
public static final int DEFAULT_TCP_CONNECT_TIMEOUT_MILLIS
public static final int DEFAULT_HANDSHAKE_TIMEOUT_MILLIS
public EncryptedSocket(java.lang.String serverHost,
int serverPort)
serverHost - the hostname or IP address of the server. SNI is supported if you pass a hostnameserverPort - the TPC/IP port of the serverconnect()public EncryptedSocket(java.lang.String severIpAddress,
java.lang.String serverHost,
int serverPort)
severIpAddress - the server IP addressserverHost - the sever hostname (used for SNI)serverPort - the TPC/IP port of the serverconnect()public void setLimitSSLVersion(java.lang.String limitSSLVersion)
limitSSLVersion - the maximal used SSL versionpublic void setTrustManager(javax.net.ssl.TrustManager[] trustManagers)
trustManagers - the X509 trust manager to validate certificate chainspublic void setClientAuthKeyManagers(javax.net.ssl.KeyManager[] clientAuthKeyManagers)
clientAuthKeyManagers - the key managers for client authenticationLoadPKCS12Certificate,
LoadPKCS12Certificate.getKeyManagers()public void setLocalOutboundAddress(java.net.InetAddress localOutboundAddress)
localOutboundAddress - the specific outbound IP addresspublic void setHandshakeCompletedListener(javax.net.ssl.HandshakeCompletedListener handshakeCompletedListener)
handshakeCompletedListener - the HandShake Completed event listenerpublic void setTCPConnectTimeoutMillis(int tcpConnectTimeoutMillis)
tcpConnectTimeoutMillis - the TCP connect timeout in millisecondsDEFAULT_TCP_CONNECT_TIMEOUT_MILLISpublic void setSSLHandshakeTimeoutMillis(int sslHandshakeTimeoutMillis)
sslHandshakeTimeoutMillis - the SSL handshake timeout in millisecondsDEFAULT_HANDSHAKE_TIMEOUT_MILLISpublic javax.net.ssl.SSLSocket connect()
throws java.security.NoSuchAlgorithmException,
java.security.KeyManagementException,
java.io.IOException
java.security.NoSuchAlgorithmException - if the SSL protocol version is not supported by the JVMjava.security.KeyManagementException - if the sources of authentication keys are invalidjava.io.IOException - if an IO exception occurredpublic long getSSLPrepareTime()
public long getTCPConnectTime()
public long getSSLHandshakeTime()