Last active
September 18, 2022 21:30
-
-
Save hshimamoto/27b397feb5dd05697c3b790a828ddaa9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks, that was a clear example, I used it here https://github.com/mau-network/mau/blob/a049629ba9d4be102faee140bbfa2b2381a6bf32/client.go#L50