Commons Net
  1. Commons Net
  2. NET-509

AuthenticatingSMTPClient needs a constructor with the isImplicit argument for SSL

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.3
    • Component/s: SMTP
    • Labels:
    • Environment:

      all

      Description

      AuthenticatingSMTPClient extends SMTPSClient but does not have a constructor with the isImplicit argument.
      Because of this we can not connect to a SSL SMTP server that requires authentication.
      According to the SMTPSClient javadoc :

      In explicit mode (the default), SSL/TLS

      • negotiation starts when the user calls execTLS() and the server accepts the command.

      Implicit usage:
      SMTPSClient c = new SMTPSClient(true);
      c.connect("127.0.0.1", 465);
      Explicit usage:
      SMTPSClient c = new SMTPSClient();
      c.connect("127.0.0.1", 25);
      if (c.execTLS())

      Unknown macro: { /rest of the commands here/ }

      So all in all, we could think this is not important to have a constructor without the isImplicit argument, since we can go the c.execTLS() way.
      But here is what happens when you use the explicit usage with AuthenticatingSMTPClient and a SSL connection (works fine with STARTTLS btw) : when you call connect(), SMTP.__getReply() is eventually called, and line 196 :

              String line = _reader.readLine();
      

      is waiting for the SMTP server to reply... BUT the smtp client did not yet initiate the SSL connection; so we just wait for the timeout to occur (since the server won't reply anything before the SSL connection is initialized).
      And if we try to call execTls() before connect(), we get a NPE because the writer is not set yet.

      I have attached a simple patch to make AuthenticatingSMTPClient works with SSL connections (again it works fine with STARTTLS already)

        Activity

        Hide
        Sebb added a comment -

        Thanks for the patch; applied with minor tweaks (e.g. restored original order of imports).

        URL: http://svn.apache.org/r1490850
        Log:
        NET-509 AuthenticatingSMTPClient needs a constructor with the isImplicit argument for SSL

        Modified:
        commons/proper/net/trunk/src/changes/changes.xml
        commons/proper/net/trunk/src/main/java/org/apache/commons/net/smtp/AuthenticatingSMTPClient.java

        Show
        Sebb added a comment - Thanks for the patch; applied with minor tweaks (e.g. restored original order of imports). URL: http://svn.apache.org/r1490850 Log: NET-509 AuthenticatingSMTPClient needs a constructor with the isImplicit argument for SSL Modified: commons/proper/net/trunk/src/changes/changes.xml commons/proper/net/trunk/src/main/java/org/apache/commons/net/smtp/AuthenticatingSMTPClient.java
        Hide
        Anthony Dahanne added a comment -

        Hello Sebb,
        thanks for applying the patch; I just had a look at https://repository.apache.org/content/groups/snapshots/commons-net/commons-net/3.3-SNAPSHOT/ to get the latest build, but it is empty.
        Is there a place to get the latest snapshots ? if not, when is the release (3.3) due for ?
        thanks again

        Show
        Anthony Dahanne added a comment - Hello Sebb, thanks for applying the patch; I just had a look at https://repository.apache.org/content/groups/snapshots/commons-net/commons-net/3.3-SNAPSHOT/ to get the latest build, but it is empty. Is there a place to get the latest snapshots ? if not, when is the release (3.3) due for ? thanks again
        Hide
        Benedikt Ritter added a comment -

        We are currently voting for release 3.3 of NET [1]. Feel free to try the RC out yourself and post any concerns you have to the dev ML.

        Regards,
        Benedikt

        [1] http://markmail.org/message/ybdfnaao2ot4xpyr

        Show
        Benedikt Ritter added a comment - We are currently voting for release 3.3 of NET [1] . Feel free to try the RC out yourself and post any concerns you have to the dev ML. Regards, Benedikt [1] http://markmail.org/message/ybdfnaao2ot4xpyr

          People

          • Assignee:
            Unassigned
            Reporter:
            Anthony Dahanne
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 0.5h
              0.5h
              Remaining:
              Remaining Estimate - 0.5h
              0.5h
              Logged:
              Time Spent - Not Specified
              Not Specified

                Development