i am trying to make https request with golang.
conf := &tls.Config{
InsecureSkipVerify: true,
MinVersion:tls.VersionTLS10,
}
//TLS connection
tlsCon, err := tls.Dial("tcp", "youtube.com:443", conf)
if err != nil {
fmt.Println("SSL Error : " + err.Error())
return
}
defer tlsCon.Close()
state := tlsCon.ConnectionState()
fmt.Println("SSL ServerName : " + state.ServerName)
fmt.Println("SSL Handshake : ", state.HandshakeComplete)
fmt.Println("SSL Mutual : ", state.NegotiatedProtocolIsMutual)
request = '
CONNECT youtube.com:443 HTTP/1.1
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:51.0) Gecko/20100101 Firefox/51.0
Proxy-Connection: close
Connection: close
Host: youtube.com:443
'
n, err = io.WriteString(tlsCon, request)
if err != nil {
fmt.Println("SSL Write error :", err.Error(), n)
}
n, err = tlsCon.Read(data)
if err != nil {
fmt.Println("SSL Read error : " + err.Error())
return
}
this is my code , state.HandshakeComplete, state.NegotiatedProtocolIsMutual returns true and state.ServerName returns = ''
when i write data to tls connection no error returns also tls connection never reply my request.
any help appricated. thanks.