I have an open TCP connection and read from it with a for loop like so
for {
// tx.Text is of type textproto.Conn
// the underlying connection is stored in tx.Conn
l, err := tx.Text.Reader.ReadLine()
// do stuff with the text line ...
}
Now I want to upgrade the connection to TLS like this (TlsConf contains a certificate loaded with tls.LoadX509KeyPair)
tx.Conn = tls.Server(tx.Conn, tx.Server.Conf.TlsConf)
tx.Text = textproto.NewConn(tx.Conn)
When I do this I get a segmentation fault on the client when the server attempts a handshake. I’m implementing a SMTP server and am testing it with swaks using the -tls flag. The terminal output of swaks is the following
-> STARTTLS
<- 220 Start TLS
Segmentation fault: 11
Since swaks is a tested tool, and worked with the nodeJS SMTP implementation I had before, I don’t suspect the error is on the client side.
What did I do wrong or what is missing?
PS: When a TLS connection is started from an existing insecure connection, what does exactly happen? Does the client establish a new connection on a different port or is the connection reused?
Ditched swaks, built a small tool to test TLS using Go’s own smtp.SendMail: