github.com/chwjbn/xclash@v0.2.0/transport/vmess/tls.go (about) 1 package vmess 2 3 import ( 4 "crypto/tls" 5 "net" 6 ) 7 8 type TLSConfig struct { 9 Host string 10 SkipCertVerify bool 11 NextProtos []string 12 } 13 14 func StreamTLSConn(conn net.Conn, cfg *TLSConfig) (net.Conn, error) { 15 tlsConfig := &tls.Config{ 16 ServerName: cfg.Host, 17 InsecureSkipVerify: cfg.SkipCertVerify, 18 NextProtos: cfg.NextProtos, 19 } 20 21 tlsConn := tls.Client(conn, tlsConfig) 22 err := tlsConn.Handshake() 23 return tlsConn, err 24 }