Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4969799

SSLSocket(InetAddress,int) shouldn't throw UnknownHostException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 5.0
    • 5.0
    • security-libs
    • b36
    • sparc
    • solaris_2.6
    • Verified



      Name: ktR10099 Date: 12/17/2003



      According to the spec for javax.net.ssl.SSLSocket.SSLSocket(InetAddress
      address, int port) it should throw "...UnknownHostException - if the host
      is not known". But current java implementation throws
      NoRouteToHostException being given weird address. Please find source,
      demonstrating the problem, below.
      ---------------------------test145.java---------------------------
      import javax.net.ssl.SSLSession;
      import javax.net.ssl.SSLSocket;
      import javax.net.ssl.HandshakeCompletedListener;
      import java.net.InetAddress;
      import java.io.IOException;

      public class test145 {
          public static void main(String[] args) {
              try {
                  byte[] addr = {2, 2, 2, 2};
                  InetAddress iaddr = InetAddress.getByAddress(addr);
                  System.out.println("Address prepared");
                  MySSLSocket ms = new MySSLSocket(iaddr, 0);
              } catch (Exception e) {
                  System.out.println(e);
              }

      System.out.println("Finished");
          }
      }

      class MySSLSocket extends SSLSocket {
          public MySSLSocket() throws IOException {
              super();
          }

          public MySSLSocket(InetAddress address, int port) throws IOException {
              super(address, port);
          }

          public MySSLSocket(InetAddress address, int port, InetAddress clientAddress, int clientPort) throws IOException {
              super(address, port, clientAddress, clientPort);
          }

          public MySSLSocket(String host, int port) throws IOException {
              super(host, port);
          }

          public MySSLSocket(String host, int port, InetAddress clientAddress, int clientPort) throws IOException {
              super(host, port, clientAddress, clientPort);
          }

          public void addHandshakeCompletedListener(HandshakeCompletedListener listener) {}

          public String[] getEnabledCipherSuites() {
              return null;
          }

          public String[] getEnabledProtocols() {
              return null;
          }

          public boolean getEnableSessionCreation() {
              return false;
          }

          public boolean getNeedClientAuth() {
              return false;
          }

          public SSLSession getSession() {
              return null;
          }

          public String[] getSupportedCipherSuites() {
              return null;
          }

          public String[] getSupportedProtocols() {
              return null;
          }

          public boolean getUseClientMode() {
              return false;
          }

          public boolean getWantClientAuth() {
              return false;
          }

          public void removeHandshakeCompletedListener(HandshakeCompletedListener listener) {}

          public void setEnabledCipherSuites(String[] suites) {}

          public void setEnabledProtocols(String[] protocols) {}

          public void setEnableSessionCreation(boolean flag) {}

          public void setNeedClientAuth(boolean need) {}

          public void setUseClientMode(boolean mode) {}

          public void setWantClientAuth(boolean want) {}

          public void startHandshake() {}
      }
      -------------------------output of test145--------------------------
      java full version "1.5.0-beta-b31"
      Address prepared
      java.net.NoRouteToHostException: Cannot assign requested address
      Finished
      ---------------------------------------------------------------------
      ======================================================================

            wetmore Bradford Wetmore
            kvtsunw Kvt Kvt (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: