Closed smil267 closed 3 years ago
tls prompt err: tls: first record does not look like a TLS handshake
I'm sorry but I can't understand what the request is here. TLS is supported. Can you share code?
Here's a test that shows how to setup TLS properly. Let us know if it doesn't work. Closing for now.
server code
`func main() {
cert, err := tls.LoadX509KeyPair("cert/xxxx.crt", "cert/xxx.key")
if err != nil {
log.Println(err)
return
}
config := &tls.Config{
Certificates: []tls.Certificate{cert}}
ln, err := tls.Listen("tcp", ":9090", config)
proxyListener := &proxyproto.Listener{
Listener: ln,
}
conn, err := proxyListener.Accept()
if err != nil {
log.Fatalf("err: %v", err)
}
defer conn.Close()
addr := conn.RemoteAddr().(*net.TCPAddr)
fmt.Println("ip====", addr.IP.String())
if addr.IP.String() != "10.1.1.1" {
log.Fatalf("bad: %v", addr)
}
if addr.Port != 1000 {
log.Fatalf("bad: %v", addr)
}
} `
client code
`func main() {
conn, err := net.Dial("tcp", "127.0.0.1:9090")
if err != nil {
log.Fatalf("err: %v", err)
}
defer conn.Close()
// Write out the header!
header := "PROXY TCP4 10.1.1.1 20.2.2.2 1000 2000\r\n"
conn.Write([]byte(header))
}`
I got the same error.
hi, when the server listen mode is tls, it isn't work. can you support tls listen?