diff options
| author | Adnan Maolood <[email protected]> | 2020-10-31 22:50:42 -0400 |
|---|---|---|
| committer | Adnan Maolood <[email protected]> | 2020-10-31 22:50:42 -0400 |
| commit | dad8f38bfba73e415db7f5c9a13acc19da7717d5 (patch) | |
| tree | 6f86463636fce1545ea9da730bba7af32900fc39 /examples | |
| parent | Add option to skip trust checks (diff) | |
| download | go-gemini-dad8f38bfba73e415db7f5c9a13acc19da7717d5.tar.xz go-gemini-dad8f38bfba73e415db7f5c9a13acc19da7717d5.zip | |
Fix examples/client.go
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/client.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/examples/client.go b/examples/client.go index 0a35cca..4c9b172 100644 --- a/examples/client.go +++ b/examples/client.go @@ -5,6 +5,7 @@ package main import ( "bufio" "crypto/tls" + "crypto/x509" "fmt" "io/ioutil" "log" @@ -30,6 +31,19 @@ var ( func init() { client.Timeout = 2 * time.Minute + client.KnownHosts.LoadDefault() + client.TrustCertificate = func(hostname string, cert *x509.Certificate) gemini.Trust { + fmt.Printf(trustPrompt, hostname, gemini.Fingerprint(cert)) + scanner.Scan() + switch scanner.Text() { + case "t": + return gemini.TrustAlways + case "o": + return gemini.TrustOnce + default: + return gemini.TrustNone + } + } client.CreateCertificate = func(hostname, path string) (tls.Certificate, error) { fmt.Println("Generating client certificate for", hostname, path) return gemini.CreateCertificate(gemini.CertificateOptions{ |