SSL problem URGENT!!!!!!!!!

2003-10-29 Thread Galbayar
I have question. when i use socket connect to ssl supported web server if
successfully connected and can get http response.
However use URL cant get http response. what happened?

import java.net.*;
import javax.net.*;
import javax.net.ssl.*;
import java.io.*;

public class ReadHttpsURL1 {
   static final int HTTPS_PORT = 443;

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

   System.setProperty(javax.net.ssl.trustStore,
D:/j2sdk1.4.1/bin/truststore);
  // Get a Socket factory
  SocketFactory factory = SSLSocketFactory.getDefault();

  // Get Socket from factory
  Socket socket = factory.createSocket(192.168.0.198, HTTPS_PORT);


  BufferedWriter out = new BufferedWriter(new
OutputStreamWriter(socket.getOutputStream()));
  BufferedReader in = new BufferedReader(
new InputStreamReader(socket.getInputStream()));
  out.write(GET /main.html HTTP/1.0\n\n);
  out.flush();

  String line;
  StringBuffer sb = new StringBuffer();
  while((line = in.readLine()) != null) {
 sb.append(line+\r\n);
  }
  out.close();
  in.close();
  System.out.println(sb.toString());
   }
}



import java.net.*;
import java.io.*;

public class ReadHttpsURL2 {
   public static void main(String argv[]) throws Exception {

System.setProperty(javax.net.ssl.trustStore,
D:/j2sdk1.4.1/bin/truststore);
  URL url = new URL(https://192.168.0.198/main.html;);
  BufferedReader in = new BufferedReader(new InputStreamReader(
url.openStream()));

  String line;
  StringBuffer sb = new StringBuffer();
  while ((line = in.readLine()) != null) {
 sb.append(line);
  }
  in.close();
  System.out.println(sb.toString());

   }
}


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: SSL problem URGENT!!!!!!!!!

2003-10-29 Thread Christopher Schultz
Galbayar,

I'm pretty sure the desire to reply to posts is inversely proportional 
to the number of trailing exclamation points in the subject line.

Also note that this problem does not sound urgent in the slightest.

I have question. when i use socket connect to ssl supported web server if
successfully connected and can get http response.
However use URL cant get http response.
I think you'll have better luck using a URLConnection (see 
java.net.URL.connect()) with a https URL.

 what happened?

What *did* happen? What do you mean can't get http response? Did it 
crash? Did it wait forever for the connection? Did it fail with a 
timeout? Did it give you a connection refused? Did your computer catch fire?

Did the server respond I'm sorry, Dave, I can't do that? If so, I 
think you've got bigger problems.

-chris

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]