TLS 连接服务器端完成握手

package main

import (
	"crypto/tls"
	"log"
)

func main() {
	tsConf := &tls.Config{
		InsecureSkipVerify: true,   // 忽略证书有效性验证
		MaxVersion:         0x0303, // 使用 TLS 1.2
		MinVersion:         0x0303,
	}

	conn, err := tls.Dial("tcp", "120.26.214.10:443", tsConf)
	if err != nil {
		log.Fatalln("Error:", err)
		return
	}

	status := conn.ConnectionState()
	hs := status.HandshakeComplete
	if !hs {
		log.Println("TLS 握手失败:[", status, "]")
		return
	}
	log.Println("TLS 握手完成:[", hs, "]")
}

输出:

2018/11/27 18:57:36 TLS 握手完成:[ true ]