Skip to content

net/smtp: NewClient should initialize tls based on the incoming connection type #22166

@aronatkins

Description

@aronatkins

What version of Go are you using (go version)?

1.9.1

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/aron/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/ts/s940qvdj5vj1czr9qh07fvtw0000gn/T/go-build463641693=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"

What did you do?

Attempted to perform SMTP PLAIN authentication over an SSL connection (without STARTTLS).

Code resembles:

conn, err := tls.Dial("tcp", "hostname:port", tlsConfig)
client, err := smtp.NewClient(conn, "hostname")
auth := smtp.PlainAuth(identity, "username", "password", "hostname")
err := client.Auth(&auth)

What did you expect to see?

Successful authentication and mail-sending.

What did you see instead?

Authentication failed with an "unencrypted connection" error.

This approach worked before #22134/#22133

smtp.NewClient could look at its incoming net.Conn and if it is an *tls.Conn, initialize Client.tls as true.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions