tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Galbayar" <galba...@mobinet.mn>
Subject SSL problem URGENT!!!!!!!!!
Date Wed, 29 Oct 2003 13:06:07 GMT
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: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message