(clientCert, clientKey string)
| 3 | import "crypto/tls" |
| 4 | |
| 5 | func NewConfig(clientCert, clientKey string) (*tls.Config, error) { |
| 6 | tlsConfig := tls.Config{ |
| 7 | MinVersion: tls.VersionTLS12, |
| 8 | } |
| 9 | |
| 10 | if clientCert != "" && clientKey != "" { |
| 11 | cert, err := tls.LoadX509KeyPair(clientCert, clientKey) |
| 12 | if err != nil { |
| 13 | return &tlsConfig, err |
| 14 | } |
| 15 | tlsConfig.Certificates = []tls.Certificate{cert} |
| 16 | } |
| 17 | |
| 18 | return &tlsConfig, nil |
| 19 | } |