Commons Net
  1. Commons Net
  2. NET-421

Problem connecting to TLS/SSL SMTP server using explicit mode

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 3.0, 3.0.1
    • Fix Version/s: 3.1
    • Component/s: SMTP
    • Labels:
      None

      Description

      Just tried to send an email through gmail servers by doing the following:

      AuthenticatingSMTPClient client = new AuthenticatingSMTPClient();
      client.connect("smtp.gmail.com", 587); // reply: 220 220 mx.google.com ESMTP
      client.login(); // reply: 250 250 mx.google.com at your service
      client.execTLS(); // reply: 220 2.0.0 Ready to start TLS
      client.auth(AUTH_METHOD.PLAIN, username, password); // exception
      ...

      Unfortunality after execTLS() I get a MalformedServerReplyException. I looked at the SMTPSClient source code and found out that the reader/writer are wrong after execTLS() got called. The performSSLNegotiation() method sets input and output to the new input/output streams from SSLSocket, but the reader/writer are still pointing to the values set inside connectAction().

      Possible fix for this issue:

      public boolean execTLS() throws SSLException, IOException
      {
      	if (!SMTPReply.isPositiveCompletion(sendCommand("STARTTLS")))
      	{
      		return false;
      		//throw new SSLException(getReplyString());
      	}
      	performSSLNegotiation();
      	_reader = new CRLFLineReader(new InputStreamReader(_input_, encoding));
          	_writer = new BufferedWriter(new OutputStreamWriter(_output_, encoding));
      	return true;
      }

        Activity

        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        1d 1h 14m 1 Sebb 30/Aug/11 14:52
        Resolved Resolved Closed Closed
        183d 5h 42m 1 Sebb 29/Feb/12 20:35
        Sebb made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Sebb made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Sebb made changes -
        Affects Version/s 3.0.1 [ 12316459 ]
        Fix Version/s 3.1 [ 12317744 ]
        Oliver Saggau made changes -
        Field Original Value New Value
        Description Just tried to send an email through gmail servers by doing the following:
        AuthenticatingSMTPClient client = new AuthenticatingSMTPClient();
        client.connect("smtp.gmail.com", 587); // reply: 220 220 mx.google.com ESMTP
        client.login(); // reply: 250 250 mx.google.com at your service
        client.execTLS(); // reply: 220 2.0.0 Ready to start TLS
        client.auth(AUTH_METHOD.PLAIN, username, password); // exception
        ...

        Unfortunality after execTLS() I get a MalformedServerReplyException. I looked at the SMTPSClient source code and found out that the reader/writer are wrong after execTLS() got called. The performSSLNegotiation() method sets _input_ and _output_ to the new input/output streams from SSLSocket, but the reader/writer are still pointing to the values set inside _connectAction_().

        Possible fix for this issue:
        {code}public boolean execTLS() throws SSLException, IOException
        {
        if (!SMTPReply.isPositiveCompletion(sendCommand("STARTTLS")))
        {
        return false;
        //throw new SSLException(getReplyString());
        }
        performSSLNegotiation();
        _reader = new CRLFLineReader(new InputStreamReader(_input_, encoding));
             _writer = new BufferedWriter(new OutputStreamWriter(_output_, encoding));
        return true;
        }{code}
        Just tried to send an email through gmail servers by doing the following:
        {code}AuthenticatingSMTPClient client = new AuthenticatingSMTPClient();
        client.connect("smtp.gmail.com", 587); // reply: 220 220 mx.google.com ESMTP
        client.login(); // reply: 250 250 mx.google.com at your service
        client.execTLS(); // reply: 220 2.0.0 Ready to start TLS
        client.auth(AUTH_METHOD.PLAIN, username, password); // exception
        ...{code}

        Unfortunality after execTLS() I get a MalformedServerReplyException. I looked at the SMTPSClient source code and found out that the reader/writer are wrong after execTLS() got called. The performSSLNegotiation() method sets _input_ and _output_ to the new input/output streams from SSLSocket, but the reader/writer are still pointing to the values set inside _connectAction_().

        Possible fix for this issue:
        {code}public boolean execTLS() throws SSLException, IOException
        {
        if (!SMTPReply.isPositiveCompletion(sendCommand("STARTTLS")))
        {
        return false;
        //throw new SSLException(getReplyString());
        }
        performSSLNegotiation();
        _reader = new CRLFLineReader(new InputStreamReader(_input_, encoding));
             _writer = new BufferedWriter(new OutputStreamWriter(_output_, encoding));
        return true;
        }{code}
        Oliver Saggau created issue -

          People

          • Assignee:
            Unassigned
            Reporter:
            Oliver Saggau
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development