Last active
September 1, 2022 15:50
-
-
Save scottopell/ec735d90b0bdb8deeff9a81424e6efef to your computer and use it in GitHub Desktop.
Where does Go get its trusted CAs from?
This file contains 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 ( | |
"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