SetCertFromFile helps to set client certificates from cert and key file.
(certFile, keyFile string)
| 269 | |
| 270 | // SetCertFromFile helps to set client certificates from cert and key file. |
| 271 | func (c *Client) SetCertFromFile(certFile, keyFile string) *Client { |
| 272 | cert, err := tls.LoadX509KeyPair(certFile, keyFile) |
| 273 | if err != nil { |
| 274 | c.log.Errorf("failed to load client cert: %v", err) |
| 275 | return c |
| 276 | } |
| 277 | config := c.GetTLSClientConfig() |
| 278 | config.Certificates = append(config.Certificates, cert) |
| 279 | return c |
| 280 | } |
| 281 | |
| 282 | // SetCerts set client certificates. |
| 283 | func (c *Client) SetCerts(certs ...tls.Certificate) *Client { |