config.go 359 B

1234567891011121314151617
  1. package tls
  2. import "crypto/tls"
  3. func NewConfig(clientCert, clientKey string) (*tls.Config, error) {
  4. tlsConfig := tls.Config{}
  5. if clientCert != "" && clientKey != "" {
  6. cert, err := tls.LoadX509KeyPair(clientCert, clientKey)
  7. if err != nil {
  8. return &tlsConfig, err
  9. }
  10. tlsConfig.Certificates = []tls.Certificate{cert}
  11. }
  12. return &tlsConfig, nil
  13. }