public interface SSLCommunication
SSLSocket
,
SSLTransport
Modifier and Type | Method and Description |
---|---|
void |
close()
Close this SSL socket.
|
CipherSuite |
getActiveCipherSuite()
Returns the active cipher suite.
|
CompressionMethod |
getActiveCompressionMethod()
Returns the active compression method.
|
int |
getActiveProtocolVersion()
Return the active SSL protocol version.
|
SSLContext |
getContext()
Returns the SSLContext of this SSLSocket.
|
java.io.InputStream |
getInputStream()
Returns an input stream for this socket.
|
java.io.OutputStream |
getOutputStream()
Returns an output stream for this socket.
|
java.security.cert.X509Certificate[] |
getPeerCertificateChain()
Returns the certificate chain sent by the peer or null if the peer
has no certificate.
|
CipherSuiteList |
getPeerSupportedCipherSuiteList()
Return the list of cipher suites known to be supported by the remote peer.
|
CompressionMethod[] |
getPeerSupportedCompressionMethods()
Return the compression methods supported by the remote peer.
|
Session |
getSession()
Returns the currently active Session for this SSLSocket.
|
boolean |
getUseClientMode()
Returns whether or not this socket resides on the client
side of the connection.
|
void |
renegotiate()
Start a renegotiating SSL handshake.
|
void |
setAutoHandshake(boolean on)
Can be used to switch off the automatic start of the handshake procedure.
|
void |
setDebugStream(java.io.OutputStream os)
Enables debugging mode.
|
void |
setDebugStream(java.io.Writer writer)
Enables debugging mode.
|
void |
setUseClientMode(boolean mode)
Select client or server mode for this socket.
|
void |
shutdown()
Shuts the SSL layer down.
|
void |
startHandshake()
Start the SSL handshake process.
|
SSLContext getContext()
void setAutoHandshake(boolean on)
If auto handshake is switched off the application has to start the handshaking process manually using the method startHandshake(). This kind of operation is used when connecting over a proxy or firewall.
on
- true if handshake should start automatically, false otherwisestartHandshake()
java.security.cert.X509Certificate[] getPeerCertificateChain()
In SSLv2 this will always just return the server's certificate (protocol limitation). Note that some SSLv3/TLS server do not include self signed certificates as those will have to be obtained and verified using a different method anyway.
int getActiveProtocolVersion()
SSLContext
CipherSuite getActiveCipherSuite()
CipherSuite
CompressionMethod getActiveCompressionMethod()
CompressionMethod
CipherSuiteList getPeerSupportedCipherSuiteList()
CipherSuite
,
getActiveCipherSuite()
CompressionMethod[] getPeerSupportedCompressionMethods()
getPeerSupportedCipherSuiteList()
, see there with
the exception of the SSLv2 case. As there are no compression
in SSLv2 the empty array is returned.CompressionMethod
,
getActiveCompressionMethod()
Session getSession()
void renegotiate() throws java.io.IOException
getSession().invalidate()
before
calling renegotiate, see below for more information.
Basically there are two reasons you might want to initiate renegotiation:
This method locks the InputStream and the OutputStream for exclusive access before proceeding with the handshake. That means that for the duration of the handshake procedure no communication is possible and more importantly that the handshake can not begin until possible blocking read() and write() calls by other threads have completed.
java.io.IOException
- if an error occurs during the handshake procedurevoid startHandshake() throws java.io.IOException
This method locks the InputStream and the OutputStream for exclusive access before proceeding with the handshake. That means that for the duration of the handshake procedure no communication is possible and more importantly that the handshake can not begin until possible blocking read() and write() calls by other threads have completed.
java.io.IOException
- if an error occurs during the handshake proceduresetAutoHandshake(boolean)
void setUseClientMode(boolean mode) throws java.io.IOException
This selection can only be made prior to the initial SSL handshake. If the method is called made afterwards an SSLException is thrown.
java.io.IOException
boolean getUseClientMode()
java.io.OutputStream getOutputStream() throws java.io.IOException
java.io.IOException
- if an error occurs when creating the output streamjava.io.InputStream getInputStream() throws java.io.IOException
java.io.IOException
- if an error occurs when creating the input stream.void setDebugStream(java.io.Writer writer)
writer
- the Writer to which debug information shall be writtenvoid setDebugStream(java.io.OutputStream os)
os
- the OutputStream to which debug information shall be writtenvoid shutdown() throws java.io.IOException
A SSL layer shutdown occurs in the following cases:
java.io.IOException
- if an I/O error occurs when closing this SSLSocketvoid close() throws java.io.IOException
This method will never be called by the library itself, it will always just call shutdown(). It is the responsibility of the application to always close the socket when communication has been completed. Once the socket has been closed read() and write() calls will throw SocketExceptions. The behaviour described here is compatible with the original Java sockets.
java.io.IOException