I'd appreciate any help or guidance about how can I fetch the Session-ID of a TLS connection.
func main() {
log.SetFlags(log.Lshortfile)
tr := &http.Transport{
DialTLS: dialTLSDefault,
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
httpClient := &http.Client{Transport: tr}
res, err := httpClient.Get("https://www.google.com/robots.txt")
if err != nil {
log.Fatal(err)
}
defer res.Body.Close()
robots, err := ioutil.ReadAll(res.Body)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%s", robots)
}
func dialTLSDefault(network, addr string) (net.Conn, error) {
fmt.Printf("Connecto to: %s %s\n ", network, addr)
cfg := &tls.Config{
InsecureSkipVerify: true,
ClientSessionCache: tls.NewLRUClientSessionCache(2),
ServerName:"www.google.com",
}
cn, err := tls.Dial(network, addr, cfg)
if err != nil {
return nil, err
}
if err := cn.Handshake(); err != nil {
return nil, err
}
if !cfg.InsecureSkipVerify {
if err := cn.VerifyHostname(cfg.ServerName); err != nil {
return nil, err
}
}
state := cn.ConnectionState()
if !state.NegotiatedProtocolIsMutual {
return nil, errors.New("http: could not negotiate protocol mutually")
}
fmt.Printf("NegotiatedProtocol: %s\n ", state.NegotiatedProtocol)
fmt.Printf("TLSUnique: %s\n ", hex.EncodeToString(state.TLSUnique))
fmt.Printf("Session-ID: %s\n ", ????)
return cn, nil
}