k3s/vendor/github.com/k3s-io/kine/pkg/tls/config.go
Jacob Blain Christen 36230daa86
[migration k3s-io] update kine dependency (#2568)
rancher/kine ➡️ k3s-io/kine

Part of https://github.com/rancher/k3s/issues/2189

Signed-off-by: Jacob Blain Christen <jacob@rancher.com>
2020-11-30 16:45:22 -07:00

32 lines
503 B
Go

package tls
import (
"crypto/tls"
"go.etcd.io/etcd/pkg/transport"
)
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{
CertFile: c.CertFile,
KeyFile: c.KeyFile,
TrustedCAFile: c.CAFile,
}
tlsConfig, err := info.ClientConfig()
if err != nil {
return nil, err
}
return tlsConfig, nil
}