k3s/vendor/github.com/k3s-io/kine/pkg/tls/config.go

32 lines
503 B
Go
Raw Normal View History

2019-08-22 05:12:46 +00:00
package tls
import (
"crypto/tls"
2019-12-12 01:27:03 +00:00
"go.etcd.io/etcd/pkg/transport"
2019-08-22 05:12:46 +00:00
)
type Config struct {
CAFile string
CertFile string
KeyFile string
}
func (c Config) ClientConfig() (*tls.Config, error) {
if c.CertFile == "" && c.KeyFile == "" && c.CAFile == "" {
return nil, nil
}
info := &transport.TLSInfo{
2019-12-12 01:27:03 +00:00
CertFile: c.CertFile,
KeyFile: c.KeyFile,
TrustedCAFile: c.CAFile,
2019-08-22 05:12:46 +00:00
}
tlsConfig, err := info.ClientConfig()
if err != nil {
return nil, err
}
return tlsConfig, nil
}