Fix examples/client.go
This commit is contained in:
parent
8181b86759
commit
dad8f38bfb
@ -28,7 +28,7 @@ type Client struct {
|
|||||||
Timeout time.Duration
|
Timeout time.Duration
|
||||||
|
|
||||||
// InsecureTrustAlways specifies whether the client should trust
|
// InsecureTrustAlways specifies whether the client should trust
|
||||||
// any certificate it recieves without checking KnownHosts
|
// any certificate it receives without checking KnownHosts
|
||||||
// or calling TrustCertificate.
|
// or calling TrustCertificate.
|
||||||
// Use with caution.
|
// Use with caution.
|
||||||
InsecureTrustAlways bool
|
InsecureTrustAlways bool
|
||||||
|
@ -5,6 +5,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
|
"crypto/x509"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
@ -30,6 +31,19 @@ var (
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
client.Timeout = 2 * time.Minute
|
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) {
|
client.CreateCertificate = func(hostname, path string) (tls.Certificate, error) {
|
||||||
fmt.Println("Generating client certificate for", hostname, path)
|
fmt.Println("Generating client certificate for", hostname, path)
|
||||||
return gemini.CreateCertificate(gemini.CertificateOptions{
|
return gemini.CreateCertificate(gemini.CertificateOptions{
|
||||||
|
Loading…
Reference in New Issue
Block a user