diff options
| author | adnano <[email protected]> | 2020-09-27 23:49:41 -0400 |
|---|---|---|
| committer | adnano <[email protected]> | 2020-09-27 23:49:41 -0400 |
| commit | ae4b458964700692dd2bc03ba3f269ea88269fda (patch) | |
| tree | 55eb3422c9b0d68d27d1a0794c5f5f0651fa5c72 /client.go | |
| parent | Remove tilde from comment (diff) | |
| download | go-gemini-ae4b458964700692dd2bc03ba3f269ea88269fda.tar.xz go-gemini-ae4b458964700692dd2bc03ba3f269ea88269fda.zip | |
Generate certificates on demand
Diffstat (limited to 'client.go')
| -rw-r--r-- | client.go | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -185,11 +185,11 @@ type Client struct { KnownHosts KnownHosts // CertificateStore contains all the certificates that the client has stored. - CertificateStore *CertificateStore + CertificateStore CertificateStore // GetCertificate, if not nil, will be called to determine which certificate // (if any) should be used for a request. - GetCertificate func(req *Request, store *CertificateStore) *tls.Certificate + GetCertificate func(hostname string, store CertificateStore) *tls.Certificate // TrustCertificate, if not nil, will be called to determine whether the // client should trust the given certificate. @@ -205,14 +205,14 @@ func (c *Client) Send(req *Request) (*Response, error) { MinVersion: tls.VersionTLS12, GetClientCertificate: func(info *tls.CertificateRequestInfo) (*tls.Certificate, error) { if c.GetCertificate != nil { - if cert := c.GetCertificate(req, c.CertificateStore); cert != nil { + if cert := c.GetCertificate(req.Hostname(), c.CertificateStore); cert != nil { return cert, nil } } - if req.Certificate == nil { - return &tls.Certificate{}, nil + if req.Certificate != nil { + return req.Certificate, nil } - return req.Certificate, nil + return &tls.Certificate{}, nil }, VerifyPeerCertificate: func(rawCerts [][]byte, _ [][]*x509.Certificate) error { // Parse the certificate |