dcsimg
How can I connect to a secure site using SSL3.0 through...
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Shuchi_Agarwal
Posted On:   Tuesday, June 20, 2000 09:06 AM

How can I connect to a secure site using SSL3.0 through a proxy using proxy authentication?

Re: How can I connect to a secure site using SSL3.0 through...

Posted By:   shiladitya_sircar  
Posted On:   Thursday, September 23, 2004 07:46 AM

I take it you are trying to connect to a web server with SSL which in other word means HTTPS request ? If this is the case - consider using raw sockets as :


public void connectionTest()
{
SSLSocket sslSocket;
try
{
sslSocket = (SSLSocket)factory.createSocket(host, port);
Writer out = new OutputStreamWriter(sslSocket.getOutputStream());
// https requires the full URL in the GET line
out.write("GET http://" + host + "/ HTTP/1.1
");
out.write("
");
out.flush();

// read response
BufferedReader in = new BufferedReader(new InputStreamReader(sslSocket
.getInputStream()));
int c;
while ((c = in.read()) != -1)
{
//System.out.write(c);
}
out.close();
in.close();
sslSocket.close();
}
catch (IOException e)
{
System.err.println(e);
}

}


Note that factory that I used is not defined since you can either use the standard SSLSocket Factory to create a factory from where you can instantiate a SSLSocket. This will work provided you have installed valid certificate. Other wise you cause the technique in http://www.javaworld.com/javatips/jw-javatip115.html
to create a dummy trustManager and dummy certififcate.

cheers
ssircar
About | Sitemap | Contact