Skip to content

Instantly share code, notes, and snippets.

@hshimamoto
Last active September 18, 2022 21:30
Show Gist options
  • Save hshimamoto/27b397feb5dd05697c3b790a828ddaa9 to your computer and use it in GitHub Desktop.
Save hshimamoto/27b397feb5dd05697c3b790a828ddaa9 to your computer and use it in GitHub Desktop.
package main
import (
"os"
"log"
"crypto/tls"
"crypto/x509"
)
func vpc(rawCerts [][]byte, verifiedChains [][]*x509.Certificate) error {
for ri, rawcert := range rawCerts {
certs, err := x509.ParseCertificates(rawcert)
if err != nil {
continue
}
for i, cert := range(certs) {
log.Println("index", ri, i)
log.Println("Issuer", cert.Issuer)
log.Println("Subject", cert.Subject)
}
}
return nil
}
func main() {
conf := &tls.Config {
VerifyPeerCertificate: vpc,
InsecureSkipVerify: true,
}
dest := "www.google.com:443"
if len(os.Args) > 1 {
dest = os.Args[1]
}
conn, err := tls.Dial("tcp", dest, conf)
if err != nil {
log.Println("Dial", err)
return
}
conn.Close()
}
@emad-elsaid
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment