Add function to write known hosts to io.Writer

This commit is contained in:
adnano
2020-09-27 14:18:30 -04:00
parent 2eb7fb9ba4
commit 013b2a4d3e
5 changed files with 32 additions and 43 deletions

View File

@@ -19,15 +19,8 @@ var (
)
func init() {
// Load the list of known hosts
knownHosts, err := gemini.LoadKnownHosts()
if err != nil {
log.Fatal(err)
}
client = &gemini.Client{
KnownHosts: knownHosts,
}
client = &gemini.Client{}
client.KnownHosts.Load()
client.TrustCertificate = func(cert *x509.Certificate, knownHosts *gemini.KnownHosts) error {
err := knownHosts.Lookup(cert)
@@ -53,12 +46,10 @@ func init() {
}
// Configure a client side certificate.
// To generate a certificate, run:
//
// openssl genrsa -out client.key 2048
// openssl ecparam -genkey -name secp384r1 -out client.key
// openssl req -new -x509 -sha512 -key client.key -out client.crt -days 365
// To generate a TLS key pair, run:
//
// go run -tags=example ../cert
var cert tls.Certificate
cert, err = tls.LoadX509KeyPair("examples/client/localhost.crt", "examples/client/localhost.key")
if err != nil {
log.Fatal(err)