37 Star 411 Fork 76

GVPrancher/rancher

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
tls.go 1.01 KB
一键复制 编辑 原始数据 按行查看 历史
Darren Shepherd 提交于 2018-02-22 22:10 . Local cluster support
package app
import (
"io/ioutil"
"github.com/rancher/types/apis/management.cattle.io/v3"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
func ReadTLSConfig(config *Config) error {
var err error
if config.ListenConfig != nil {
return nil
}
lc := &v3.ListenConfig{
TypeMeta: metav1.TypeMeta{
Kind: "ListenConfig",
APIVersion: "management.cattle.io/v3",
},
ObjectMeta: metav1.ObjectMeta{
Name: "cli-config",
},
Enabled: true,
}
lc.CACerts, err = readPEM("/etc/rancher/ssl/cacerts.pem")
if err != nil {
return err
}
lc.Key, err = readPEM("/etc/rancher/ssl/key.pem")
if err != nil {
return err
}
lc.Cert, err = readPEM("/etc/rancher/ssl/cert.pem")
if err != nil {
return err
}
lc.Mode = "https"
if len(config.ACMEDomains) > 0 {
lc.Mode = "acme"
lc.Domains = config.ACMEDomains
}
config.ListenConfig = lc
return nil
}
func readPEM(path string) (string, error) {
content, err := ioutil.ReadFile(path)
if err != nil {
return "", nil
}
return string(content), nil
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/rancher/rancher.git
git@gitee.com:rancher/rancher.git
rancher
rancher
rancher
v2.0.0-alpha25

搜索帮助