From d56b1c2f830b59a147ff7a38ea1ddda044661d1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Mon, 6 Dec 2021 10:54:43 +0800 Subject: [PATCH] =?UTF-8?q?SSL=E8=AF=81=E4=B9=A6=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E8=AE=BE=E7=BD=AELeaf=E5=AD=97=E6=AE=B5=E4=BB=A5=E6=8F=90?= =?UTF-8?q?=E5=8D=87=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/serverconfigs/sslconfigs/ssl_cert_config.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/pkg/serverconfigs/sslconfigs/ssl_cert_config.go b/pkg/serverconfigs/sslconfigs/ssl_cert_config.go index 598be97..5b771f1 100644 --- a/pkg/serverconfigs/sslconfigs/ssl_cert_config.go +++ b/pkg/serverconfigs/sslconfigs/ssl_cert_config.go @@ -11,7 +11,7 @@ import ( "time" ) -// SSL证书 +// SSLCertConfig SSL证书 type SSLCertConfig struct { Id int64 `yaml:"id" json:"id"` IsOn bool `yaml:"isOn" json:"isOn"` @@ -34,7 +34,7 @@ type SSLCertConfig struct { timeEnd time.Time } -// 校验 +// Init 校验 func (this *SSLCertConfig) Init() error { var commonNames []string // 发行组织 var dnsNames []string // 域名 @@ -91,6 +91,11 @@ func (this *SSLCertConfig) Init() error { if err != nil { continue } + + if cert.Leaf == nil { + cert.Leaf = c + } + for _, dnsName := range c.DNSNames { if !lists.ContainsString(dnsNames, dnsName) { dnsNames = append(dnsNames, dnsName) @@ -117,7 +122,7 @@ func (this *SSLCertConfig) Init() error { return nil } -// 校验是否匹配某个域名 +// MatchDomain 校验是否匹配某个域名 func (this *SSLCertConfig) MatchDomain(domain string) bool { if len(this.DNSNames) == 0 { return false @@ -125,17 +130,17 @@ func (this *SSLCertConfig) MatchDomain(domain string) bool { return configutils.MatchDomains(this.DNSNames, domain) } -// 获取证书对象 +// CertObject 获取证书对象 func (this *SSLCertConfig) CertObject() *tls.Certificate { return this.cert } -// 开始时间 +// TimeBegin 开始时间 func (this *SSLCertConfig) TimeBegin() time.Time { return this.timeBegin } -// 结束时间 +// TimeEnd 结束时间 func (this *SSLCertConfig) TimeEnd() time.Time { return this.timeEnd }