1
0
mirror of https://git.sr.ht/~adnano/go-gemini synced 2024-11-23 12:42:13 +01:00

Fix client example

This commit is contained in:
adnano 2020-09-26 14:01:06 -04:00
parent 82c374ea96
commit b0b5c011d3

@ -5,7 +5,6 @@ package main
import (
"bufio"
"crypto/tls"
"crypto/x509"
"fmt"
"log"
"os"
@ -14,17 +13,21 @@ import (
)
var (
client = &gemini.Client{
KnownHosts: gemini.LoadKnownHosts(),
TrustCertificate: func(cert *x509.Certificate, knownHosts *gemini.KnownHosts) error {
// Trust all certificates
return nil
},
}
client *gemini.Client
cert tls.Certificate
)
func init() {
// Load the list of known hosts
knownHosts, err := gemini.LoadKnownHosts()
if err != nil {
log.Fatal(err)
}
client = &gemini.Client{
KnownHosts: knownHosts,
}
// Configure a client side certificate.
// To generate a certificate, run:
//
@ -32,7 +35,6 @@ func init() {
// openssl ecparam -genkey -name secp384r1 -out client.key
// openssl req -new -x509 -sha512 -key client.key -out client.crt -days 365
//
var err error
cert, err = tls.LoadX509KeyPair("examples/client/client.crt", "examples/client/client.key")
if err != nil {
log.Fatal(err)