Uploaded image for project: 'Commons Net'
  1. Commons Net
  2. NET-689

Hostname is not set on the SSLSocket causing isEndpointCheckingEnabled to fail

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.7
    • 3.7.2
    • None
    • None

    Description

      When connecting with ssl to an ftps server, the hostname used to connect to the server is not copied to the SSLSocket, instead the sockets ip address is used. This applies to both with `AUTH TLS` and implicit SSL.

       

      The problem seems to be line 912 in FTPSclient.java:

      return f.createSocket(socket, socket.getInetAddress().getHostAddress(), socket.getPort(), false);

       

      which forces the new SSLSocket to have the ip address as peer hostname, which makes it impossible to use `isEndpointCheckingEnabled` as the hostname is the ip address, not the hostname that appears in the certificate.

      LFTP https://lftp.yar.ru/ correctly connects to the hostname if the name matches, and disconnects if the name doesn't match the hostname, as does OpenSSL.

      The fix would be very easy. Just change the line into

      return f.createSocket(socket, _hostname_, socket.getPort(), false);
      
      

      and it works. I tested this by simply debugging the code 

      Attachments

        Activity

          People

            Unassigned Unassigned
            ck1962 Charlie
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: