aboutsummaryrefslogtreecommitdiff
path: root/client.go
diff options
context:
space:
mode:
authoradnano <[email protected]>2020-09-27 23:49:41 -0400
committeradnano <[email protected]>2020-09-27 23:49:41 -0400
commitae4b458964700692dd2bc03ba3f269ea88269fda (patch)
tree55eb3422c9b0d68d27d1a0794c5f5f0651fa5c72 /client.go
parentRemove tilde from comment (diff)
downloadgo-gemini-ae4b458964700692dd2bc03ba3f269ea88269fda.tar.xz
go-gemini-ae4b458964700692dd2bc03ba3f269ea88269fda.zip
Generate certificates on demand
Diffstat (limited to 'client.go')
-rw-r--r--client.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/client.go b/client.go
index 504fd18..37b1b6d 100644
--- a/client.go
+++ b/client.go
@@ -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