Fix client example
This commit is contained in:
parent
d3002cc8b4
commit
4b0f94157c
|
@ -5,7 +5,6 @@ package main
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"crypto/x509"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
@ -14,17 +13,21 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
client = &gemini.Client{
|
client *gemini.Client
|
||||||
KnownHosts: gemini.LoadKnownHosts(),
|
cert tls.Certificate
|
||||||
TrustCertificate: func(cert *x509.Certificate, knownHosts *gemini.KnownHosts) error {
|
|
||||||
// Trust all certificates
|
|
||||||
return nil
|
|
||||||
},
|
|
||||||
}
|
|
||||||
cert tls.Certificate
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
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.
|
// Configure a client side certificate.
|
||||||
// To generate a certificate, run:
|
// To generate a certificate, run:
|
||||||
//
|
//
|
||||||
|
@ -32,7 +35,6 @@ func init() {
|
||||||
// openssl ecparam -genkey -name secp384r1 -out client.key
|
// openssl ecparam -genkey -name secp384r1 -out client.key
|
||||||
// openssl req -new -x509 -sha512 -key client.key -out client.crt -days 365
|
// 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")
|
cert, err = tls.LoadX509KeyPair("examples/client/client.crt", "examples/client/client.key")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user