diff --git a/client.go b/client.go index bbdbf24..be6d81d 100644 --- a/client.go +++ b/client.go @@ -185,7 +185,7 @@ type Client struct { // TrustCertificate, if not nil, will be called to determine whether the // client should trust the given certificate. // If error is not nil, the connection will be aborted. - TrustCertificate func(req *Request, cert *x509.Certificate, knownHosts *KnownHosts) error + TrustCertificate func(hostname string, cert *x509.Certificate, knownHosts *KnownHosts) error } // Send sends a Gemini request and returns a Gemini response. @@ -219,7 +219,7 @@ func (c *Client) Send(req *Request) (*Response, error) { if err := c.KnownHosts.Lookup(req.Hostname(), cert); err != nil { return err } - } else if err := c.TrustCertificate(req, cert, &c.KnownHosts); err != nil { + } else if err := c.TrustCertificate(req.Hostname(), cert, &c.KnownHosts); err != nil { return err } return nil diff --git a/examples/client/client.go b/examples/client/client.go index 387fb47..5b853de 100644 --- a/examples/client/client.go +++ b/examples/client/client.go @@ -22,8 +22,8 @@ func init() { client = &gemini.Client{} client.KnownHosts.Load() - client.TrustCertificate = func(req *gemini.Request, cert *x509.Certificate, knownHosts *gemini.KnownHosts) error { - err := knownHosts.Lookup(req.Hostname(), cert) + client.TrustCertificate = func(hostname string, cert *x509.Certificate, knownHosts *gemini.KnownHosts) error { + err := knownHosts.Lookup(hostname, cert) if err != nil { switch err { case gemini.ErrCertificateNotTrusted: @@ -37,7 +37,7 @@ func init() { return nil } else if userTrustsCertificatePermanently() { // Add the certificate to the known hosts file - knownHosts.Add(req.Hostname(), cert) + knownHosts.Add(hostname, cert) return nil } } diff --git a/gemini.go b/gemini.go index f2185e3..59c6101 100644 --- a/gemini.go +++ b/gemini.go @@ -48,11 +48,11 @@ var DefaultClient *Client func init() { DefaultClient = &Client{ - TrustCertificate: func(req *Request, cert *x509.Certificate, knownHosts *KnownHosts) error { + TrustCertificate: func(hostname string, cert *x509.Certificate, knownHosts *KnownHosts) error { // Load the hosts only once. This is so that the hosts don't have to be loaded // for those using their own clients. setupDefaultClientOnce.Do(setupDefaultClient) - return knownHosts.Lookup(req.Hostname(), cert) + return knownHosts.Lookup(hostname, cert) }, } }