Skip to content

Instantly share code, notes, and snippets.

@scottopell
Last active September 1, 2022 15:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottopell/ec735d90b0bdb8deeff9a81424e6efef to your computer and use it in GitHub Desktop.
Save scottopell/ec735d90b0bdb8deeff9a81424e6efef to your computer and use it in GitHub Desktop.
Where does Go get its trusted CAs from?
package main
import (
"crypto/tls"
"fmt"
)
// go build && strace -o strace-out.txt -f -e trace=file ./simpleget
func main() {
conn, err := tls.Dial("tcp", "www.google.com:443", nil)
if err != nil {
fmt.Println("Error in Dial", err)
return
}
defer conn.Close()
state := conn.ConnectionState()
fmt.Printf("Connection has %d Verified Chains\n", len(state.VerifiedChains))
for i, chain := range state.VerifiedChains {
fmt.Printf("Chain %d:\n", i)
for _, cert := range chain {
fmt.Printf("\tIssuer Name: %s\n", cert.Issuer)
fmt.Printf("\tExpiry: %s \n", cert.NotAfter.Format("2006-January-02"))
fmt.Printf("\tCommon Name: %s \n", cert.Issuer.CommonName)
fmt.Println("\t-------------")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment