COM.claymoresystems.ptls
Class SSLSocket
Socket
COM.claymoresystems.ptls.SSLSocket
- SSLSocketXInt
public class SSLSocket
extends Socket
SSLSocket.java
Copyright (C) 1999, Claymore Systems, Inc.
All Rights Reserved.
ekr@rtfm.com Tue May 18 09:30:32 1999
This package is a SSLv3/TLS implementation written by Eric Rescorla
<ekr@rtfm.com> and licensed by Claymore Systems, Inc.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software
must display the following acknowledgement:
This product includes software developed by Claymore Systems, Inc.
4. Neither the name of Claymore Systems, Inc. nor the name of Eric
Rescorla may be used to endorse or promote products derived from this
software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
$Id: SSLSocket.java,v 1.17 2002/03/01 17:10:37 ekr Exp $
SSLSocket()
|
SSLSocket(SSLContext ctx, InetAddress addr, int port) - Creates a stream socket and connects it to the specified port number at the specified IP address performing the SSL Handshake
|
SSLSocket(SSLContext ctx, InetAddress addr, int port, InetAddress localAddr, int localPort) - Creates a stream socket and connects it to the specified port number at the specified IP address performing the SSL Handshake
|
SSLSocket(SSLContext ctx, InputStream input, OutputStream output, String host, int port, int how) - Create an SSLSocket and connect it to the server on the
using the specified input stream and output stream
|
SSLSocket(SSLContext ctx, Socket sock, String host, int port, int how) - Create an SSLSocket around the specified socket.
|
SSLSocket(SSLContext ctx, String remote_addr, Integer remote_port) - Create an SSLSocket and connect it to the server on the
specified host and port, doing the SSLHandshake.
|
SSLSocket(SSLContext ctx, String remote_addr, int port) - Create an SSLSocket and connect it to the server on the
specified host and port, doing the SSLHandshake
|
SSLSocket(SSLContext ctx, String host, int port, InetAddress localAddr, int localPort) - Creates a stream socket and connects it to the specified port number at the specified host, performing the SSL Handshake
|
void | _stompOutputStream(java.io.OutputStream out)
|
void | close() - close the connection.
|
Vector | getCertificateChain() - get the certificate chain presented by the peer.
|
int | getCipherSuite() - Get the cipherSuite in use on this socket, as an
integer
|
InputStream | getInputStream() - Get the input stream associated with this socket.
|
OutputStream | getOutputStream() - Get the input stream associated with this socket.
|
SSLPolicyInt | getPolicy() - Get the policy associated with this socket
|
byte[] | getSessionID() - Get the SessionID associated with this socket
|
int | getVersion() - Get the version of SSL negotiated.
|
void | handshake() - Handshake.
|
void | hardClose() - Hard close.
|
static void | main(args[] ) - Test code
|
void | renegotiate() - Renegotiate the SSL connection using the same policy
This is mainly useful when a client is responding to a server's
request for renegotiation
|
void | renegotiate(SSLPolicyInt policy) - Renegotiate the SSL connection using the given policy
This is useful (for instance) for a server to renegotiate
using client authentication
|
void | sendClose() - Send our half of the SSL close_notify handshake
|
String | toString() - Converts this socket to a string
|
void | waitForClose(boolean enforceFinished) - Wait to receive a close_notify from the other side.
|
SSLSocket
public SSLSocket()
SSLSocket
public SSLSocket(SSLContext ctx,
InetAddress addr,
int port)
throws IOException
Creates a stream socket and connects it to the specified port number at the specified IP address performing the SSL Handshake
ctx
- the SSLContext to use to create this socketaddr
- the address to connect toport
- the port to connect to
SSLSocket
public SSLSocket(SSLContext ctx,
InetAddress addr,
int port,
InetAddress localAddr,
int localPort)
throws IOException
Creates a stream socket and connects it to the specified port number at the specified IP address performing the SSL Handshake
ctx
- the SSLContext to use to create this socketaddr
- the address to connect toport
- the port to connect tolocalAddr
- the local address to bind tolocalPort
- the local port to bind to
SSLSocket
public SSLSocket(SSLContext ctx,
InputStream input,
OutputStream output,
String host,
int port,
int how)
throws IllegalArgumentException,
IOException
Create an SSLSocket and connect it to the server on the
using the specified input stream and output stream
ctx
- the SSLContext to use to create this socketinput
- where data is read fromoutput
- where data is written toport
- the port to connect to (used for session resumption: the host/port pair should be unique)how
- which role to take in handshake SSLSocket.CLIENT or SSLSocket.SERVER
SSLSocket
public SSLSocket(SSLContext ctx,
Socket sock,
String host,
int port,
int how)
throws IllegalArgumentException,
IOException
Create an SSLSocket around the specified socket.
Provided by Ronald Tschalar
ctx
- the SSLContext to use to create this socketport
- the port to connect to (used for session resumption: the host/port pair should be unique)how
- which role to take in handshake SSLSocket.CLIENT or SSLSocket.SERVER
SSLSocket
public SSLSocket(SSLContext ctx,
String remote_addr,
Integer remote_port)
throws java.net.UnknownHostException,
java.io.IOException
Create an SSLSocket and connect it to the server on the
specified host and port, doing the SSLHandshake.
We need this to support the CSJ interface, which is why
it duplicates the "int" version.
ctx
- the SSLContext to use to create this socketremote_addr
- the hostname of the remote machine to connect toremote_port
- the port to connect to
SSLSocket
public SSLSocket(SSLContext ctx,
String remote_addr,
int port)
throws java.net.UnknownHostException,
java.io.IOException
Create an SSLSocket and connect it to the server on the
specified host and port, doing the SSLHandshake
ctx
- the SSLContext to use to create this socketremote_addr
- the hostname of the remote machine to connect toport
- the port to connect to
SSLSocket
public SSLSocket(SSLContext ctx,
String host,
int port,
InetAddress localAddr,
int localPort)
throws IOException
Creates a stream socket and connects it to the specified port number at the specified host, performing the SSL Handshake
ctx
- the SSLContext to use to create this sockethost
- the address to connect toport
- the port to connect tolocalAddr
- the local address to bind tolocalPort
- the local port to bind to
_stompOutputStream
public void _stompOutputStream(java.io.OutputStream out)
close
public void close()
throws java.io.IOException
close the connection. This executes the closure procedure
and throws an error if the close_notify exchange doesn't
succeed.
getCertificateChain
public Vector getCertificateChain()
throws IOException
get the certificate chain presented by the peer. This is relevant
for clients and servers if Client Authentication is being used.
- getCertificateChain in interface SSLSocketXInt
- the certificate chain as a Vector of X509Certs, null if unavailable The root is at 0 and the user cert is at n-1
getCipherSuite
public int getCipherSuite()
throws IOException
Get the cipherSuite in use on this socket, as an
integer
- getCipherSuite in interface SSLSocketXInt
getInputStream
public InputStream getInputStream()
Get the input stream associated with this socket.
Data read from this input stream is automatically SSL
decrypted
getOutputStream
public OutputStream getOutputStream()
Get the input stream associated with this socket.
Data read from this input stream is automatically SSL
encrypted
getSessionID
public byte[] getSessionID()
throws IOException
Get the SessionID associated with this socket
- getSessionID in interface SSLSocketXInt
- the session ID or null if none
getVersion
public int getVersion()
throws IOException
Get the version of SSL negotiated.
- getVersion in interface SSLSocketXInt
- 768 (0x300) for SSLv3 or 769 (0x301) for TLSv1
handshake
public void handshake()
throws IOException
Handshake. Used when automatic handshaking on connect
is turned off
hardClose
public void hardClose()
throws java.io.IOException
Hard close. Don't do SSL closure
main
public static void main(args[] )
throws java.net.UnknownHostException,
java.io.IOException
Test code
renegotiate
public void renegotiate()
throws IOException
Renegotiate the SSL connection using the same policy
This is mainly useful when a client is responding to a server's
request for renegotiation
renegotiate
public void renegotiate(SSLPolicyInt policy)
throws IOException
Renegotiate the SSL connection using the given policy
This is useful (for instance) for a server to renegotiate
using client authentication
- renegotiate in interface SSLSocketXInt
policy
- the policy to use
sendClose
public void sendClose()
throws java.io.IOException
Send our half of the SSL close_notify handshake
- sendClose in interface SSLSocketXInt
toString
public String toString()
Converts this socket to a string
- a string description of this socket
waitForClose
public void waitForClose(boolean enforceFinished)
throws java.io.IOException
Wait to receive a close_notify from the other side.
- waitForClose in interface SSLSocketXInt
enforceFinished
- insist that no more data be present on the connection before the close_notify is received. This ensures that the application has read all the data that the peer sent
Copyright (c) 1999-2001 Claymore Systems, Inc., All Rights Reserved.