usnistgov / dane_tester

3 stars 1 forks source link

Message not helpfull: "Unexpected SMTP Error 'str' does not support the buffer interface" #4

Open TheTesla opened 6 years ago

TheTesla commented 6 years ago

I do not know what this message wants to say: "Unexpected SMTP Error 'str' does not support the buffer interface while connected to SMTP server on IPaddr 212.47.246.243"

Can you please generate a better message?

https://dane-test.had.dnsops.gov/server/dane_check.cgi?host=testserver.smartrns.net

201 | testserver.smartrns.net. | 212.47.246.243 | FAILED | Server must have working SMTP server on IP address Unexpected SMTP Error 'str' does not support the buffer interface while connected to SMTP server on IPaddr 212.47.246.243
-- | -- | -- | -- | --
scottr-nist commented 6 years ago

Not sure what is causing that. It appears to be a Python3 thing which I just learned about. Will have to dig around more.

simsong commented 6 years ago

Okay. The message is being generated on line 895, here:

    except (Exception) as e:
        ret += [ DaneTestResult(test=TEST_SMTP_CONNECT,
                                passed = False,
                                hostname=hostname,
                                ipaddr=ipaddr,
                                what="Unexpected SMTP Error {} while connected to SMTP server on IPaddr {}".
                                format(str(e),ipaddr)) ]

We know that this code is being executed:

        c = smtplib.SMTP(ipaddr)
        ret += [ DaneTestResult(test=TEST_SMTP_CONNECT,
                                passed=True if c else False,
                                hostname=hostname,
                                ipaddr=ipaddr,
                                what="Checking for SMTP server on IPaddr {}".format(ipaddr)) ]

So the exception is being generated somewhere in here:

      if not c:
            return ret
        (code,resp) = c.ehlo("THERE")
        ret += [ DaneTestResult(test=TEST_SMTP_STARTTLS,
                                passed="STARTTLS" in resp,
                                hostname=hostname,
                                ipaddr=ipaddr,
                                what="Checking for STARTTLS") ]
        (code,resp) = c.starttls()
        ret += [ DaneTestResult(test=TEST_SMTP_TLS,
                                passed=code==220,
                                hostname=hostname,
                                ipaddr=ipaddr,
                                what="Executing STARTTLS") ]
        (code,resp) = c.quit()
        ret += [ DaneTestResult(test=TEST_SMTP_QUIT,
                                passed=code==221,
                                hostname=hostname,
                                ipaddr=ipaddr,
                                what="Executing QUIT") ]

The text of the exception is actually:

'str' does not support the buffer interface

But we don't know which line number it's being generated in, and we don't have a stack trace.

It looks like somewhere a string is being written to a binary output without being encoded as UTF-8.

The question is this --- why is this code failing on testserver.smartrns.net when it works on other servers? What's different about that server?

TheTesla commented 6 years ago

Maybe address blacklisting in server side or some other error messages from server?

Am 19. Januar 2018 03:17:31 MEZ schrieb "Simson L. Garfinkel" notifications@github.com:

Okay. The message is being generated on line 895, here:

   except (Exception) as e:
       ret += [ DaneTestResult(test=TEST_SMTP_CONNECT,
                               passed = False,
                               hostname=hostname,
                               ipaddr=ipaddr,

what="Unexpected SMTP Error {} while connected to SMTP server on IPaddr {}". format(str(e),ipaddr)) ]

We know that this code is being executed:

       c = smtplib.SMTP(ipaddr)
       ret += [ DaneTestResult(test=TEST_SMTP_CONNECT,
                               passed=True if c else False,
                               hostname=hostname,
                               ipaddr=ipaddr,
    what="Checking for SMTP server on IPaddr {}".format(ipaddr)) ]

So the exception is being generated somewhere in here:

     if not c:
           return ret
       (code,resp) = c.ehlo("THERE")
       ret += [ DaneTestResult(test=TEST_SMTP_STARTTLS,
                               passed="STARTTLS" in resp,
                               hostname=hostname,
                               ipaddr=ipaddr,
                               what="Checking for STARTTLS") ]
       (code,resp) = c.starttls()
       ret += [ DaneTestResult(test=TEST_SMTP_TLS,
                               passed=code==220,
                               hostname=hostname,
                               ipaddr=ipaddr,
                               what="Executing STARTTLS") ]
       (code,resp) = c.quit()
       ret += [ DaneTestResult(test=TEST_SMTP_QUIT,
                               passed=code==221,
                               hostname=hostname,
                               ipaddr=ipaddr,
                               what="Executing QUIT") ]

The text of the exception is actually:

'str' does not support the buffer interface

But we don't know which line number it's being generated in, and we don't have a stack trace.

It looks like somewhere a string is being written to a binary output without being encoded as UTF-8.

The question is this --- why is this code failing on testserver.smartrns.net when it works on other servers? What's different about that server?

-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/usnistgov/dane_tester/issues/4#issuecomment-358846379

-- Diese Nachricht wurde von meinem Android-Gerät mit K-9 Mail gesendet.

TheTesla commented 6 years ago

I see the same problem on other domains:

https://dane-test.had.dnsops.gov/server/dane_check.cgi?host=unixadm.org

scottr-nist commented 6 years ago

issue seems to be here: ret += [ DaneTestResult(test=TEST_SMTP_STARTTLS,

passed="STARTTLS" in resp,

hostname=hostname, ipaddr=ipaddr, what="Checking for STARTTLS") ]

If that is switched to something else, it seems to be fine. Does this need to be here? this is after the c.ehlo() call and doesn't seem to work even when STARTTLS is in the resp.

simsong commented 6 years ago

Oh. If that is the offending line, try changing “STARTTLS” to b”STARTTLS”

On Jan 23, 2018, at 2:31 PM, Scott Rose notifications@github.com wrote:

issue seems to be here: ret += [ DaneTestResult(test=TEST_SMTP_STARTTLS,

passed="STARTTLS" in resp, hostname=hostname, ipaddr=ipaddr, what="Checking for STARTTLS") ]

If that is switched to something else, it seems to be fine. Does this need to be here? this is after the c.ehlo() call and doesn't seem to work even when STARTTLS is in the resp.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/usnistgov/dane_tester/issues/4#issuecomment-359903500, or mute the thread https://github.com/notifications/unsubscribe-auth/ABhTrMteSIpVqt68tywI9N5mBqTrKYd6ks5tNjOjgaJpZM4RdppR.

scottr-nist commented 6 years ago

That works. closing the issue if it works for other servers

simsong commented 6 years ago

Yea! Thanks. Please push your change back to the repo.

On Jan 24, 2018, at 9:48 AM, Scott Rose notifications@github.com wrote:

That works.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/usnistgov/dane_tester/issues/4#issuecomment-360158358, or mute the thread https://github.com/notifications/unsubscribe-auth/ABhTrEzu0eu6ipDkvxcYv9K_rWcBnjsqks5tN0LKgaJpZM4RdppR.