Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

question on handshake with ssl connection
I am going to write a proxy server with Jave.
It is mainly for testing purpose and logging all the connection data
of the users.
However, i become confuse while implement the part on HTTPS request
with JSSE.
Let me tell what i have done briefly

When the thread start, a ServerSocket was create at port 8080,
which is the proxy port of all user's browser.
my program should become a middle man between the browsers and
destinate host
after receive the resquest from browser,
and on the other site, the program should make another handshake to
destinate host before forward the modified request.
I found that the broswer haven't get any response after i forward the
response header from remote host, which status code is 200.

the program should handshake with the browser, right?
however, there is an exception if i just use starthandshake() at the
beginning
and i know that a simple Socket should be used instead of SSLSocket
before handshaking.

So, the question is how can i act handshaking with the broswer?
is there any method or package can help me to do so?
or i should write a set of coding myself for HelloClient, etc???

Thanks for your help.

Here is my coding

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.net.ServerSocket;
import java.net.Socket;

import javax.net.ssl.SSLSocketFactory;

public class Test {

public static final String TARGET_HTTPS_SERVER = "localhost";
//this model is just simulate to https://localhost basically
public static final int    TARGET_HTTPS_PORT   = 443;

public static void main(String[] args) throws Exception {

ServerSocket serverSocket = new ServerSocket(8080);
while (true){

Socket soc = serverSocket.accept();

BufferedReader br = new BufferedReader(
new InputStreamReader(soc.getInputStream()));
//reading inputstream was skipped

//should i start the handshake here? how?

Writer ou = new OutputStreamWriter(
soc.getOutputStream(), "ISO-8859-1");

Socket socket = SSLSocketFactory.getDefault().createSocket(
TARGET_HTTPS_SERVER, TARGET_HTTPS_PORT);

try {
//System.out.println("here");
Writer out = new OutputStreamWriter(
socket.getOutputStream(), "ISO-8859-1");
out.write("GET / HTTP/1.1\r\n");
out.write("Host: " + TARGET_HTTPS_SERVER + ":" +
TARGET_HTTPS_PORT + "\r\n");
out.write("Agent: SSL-TEST\r\n");
out.write("\r\n");
out.flush();
BufferedReader in = new BufferedReader(
new InputStreamReader(socket.getInputStream(),
"ISO-8859-1"));
String line = null;
while ((line = in.readLine()) != null) {
System.out.println(line);
ou.write(line+"\r\n");
}
ou.flush();
//after flushing the stream, the browser hasn't any
response since handshaking was not done
} finally {
socket.close();
}
}
}
}

Report this thread to moderator Post Follow-up to this message
Old Post
Jakekeke
10-19-04 02:06 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Java Security archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:59 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.