1 Reply Latest reply on Mar 7, 2006 5:24 PM by bparanj

    JBoss SSL Setup for remote clients

    bparanj

      Hi,

      I followed the instructions at
      http://wiki.jboss.org/wiki/Wiki.jsp?page=SSLSetup

      I was able to get the ReadHttpsURL2.java working. The problem is that it works only if I use localhost in the URL and run it on the same machine. If I run the client on a remote machine I get the following error:

      Exception in thread "main" java.io.IOException: HTTPS hostname wrong: should be

      <Neptune>

      at com.ibm.net.ssl.www.protocol.https.b.b(Unknown Source)
      at com.ibm.net.ssl.www.protocol.https.b.o(Unknown Source)
      at com.ibm.net.ssl.www.protocol.https.q.connect(Unknown Source)
      at com.ibm.net.ssl.www.protocol.http.cg.getInputStream(Unknown Source)
      at com.ibm.net.ssl.www.protocol.https.t.getInputStream(Unknown Source)
      at java.net.URL.openStream(URL.java:941)
      at acme.ReadHttpsURL2.main(ReadHttpsURL2.java:16)

      Any pointers on how I can fix this?

      Thanks in advance.
      Bala

        • 1. Re: JBoss SSL Setup for remote clients
          bparanj

          I resolved this error message. SSL setup instructions on Wiki works if I use localhost but fails if I run it from a remote machine and use the machine's name.

          I modified the Http client based on the Sun's tutorial. Here is the fix:

          import java.io.BufferedReader;
          import java.io.InputStreamReader;
          import java.net.URL;
          
          import javax.net.ssl.HostnameVerifier;
          import javax.net.ssl.HttpsURLConnection;
          import javax.net.ssl.SSLSession;
          
          public class ReadHttpsURL3 {
           public static void main(String[] argv) throws Exception {
           URL url = new URL(argv[0]);
           HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
           connection.setHostnameVerifier(new MyVerified());
           connection.setDoOutput(true);
           BufferedReader in = new BufferedReader(
           new InputStreamReader(connection.getInputStream()));
           String line;
           while ((line = in.readLine()) != null) {
           System.out.println(line);
           }
           in.close();
           }
          }
          
          class MyVerified implements HostnameVerifier {
           public boolean verify(String hostname, SSLSession session) {
           return true ;
           }
          }
          


          Also make sure that you use Sun's JDK 1.4.2 or higher. I was getting some weird errors due to IBM's JVM.

          Hope this helps someone.
          Bala
          http://www.ProblemSolvingSkill.net