package main
import (
"crypto/tls"
"fmt"
"net/http"
)
func main() {
tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
client := &http.Client{Transport: tr}
seedUrl := "https://www.phpip.com"
resp, err := client.Get(seedUrl)
defer resp.Body.Close()
if err != nil {
fmt.Errorf(seedUrl," 请求失败")
panic(err)
}
//fmt.Println(resp.TLS.PeerCertificates[0])
certInfo:=resp.TLS.PeerCertificates[0]
fmt.Println("过期时间:",certInfo.NotAfter)
fmt.Println("组织信息:",certInfo.Subject)
}
输出结果如下:
过期时间: 2019-05-19 04:37:15 +0000 UTC
组织信息: CN=8100.cc
有疑问加站长微信联系(非本文作者)