mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
36230daa86
rancher/kine ➡️ k3s-io/kine Part of https://github.com/rancher/k3s/issues/2189 Signed-off-by: Jacob Blain Christen <jacob@rancher.com>
32 lines
503 B
Go
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
|
|
}
|