feat: 导入证书支持 IP 证书 (#2959)

pull/2965/head
zhengkunwang 1 year ago committed by GitHub
parent dc51148a29
commit abaa42af88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -341,10 +341,18 @@ func (w WebsiteSSLService) Upload(req request.WebsiteSSLUpload) error {
} else { } else {
newSSL.Organization = cert.Issuer.CommonName newSSL.Organization = cert.Issuer.CommonName
} }
var domains []string
if len(cert.DNSNames) > 0 { if len(cert.DNSNames) > 0 {
newSSL.PrimaryDomain = cert.DNSNames[0] newSSL.PrimaryDomain = cert.DNSNames[0]
newSSL.Domains = strings.Join(cert.DNSNames, ",") domains = cert.DNSNames[1:]
} else if len(cert.IPAddresses) > 0 {
newSSL.PrimaryDomain = cert.IPAddresses[0].String()
for _, ip := range cert.IPAddresses[1:] {
domains = append(domains, ip.String())
}
} }
newSSL.Domains = strings.Join(domains, ",")
return websiteSSLRepo.Create(context.Background(), newSSL) return websiteSSLRepo.Create(context.Background(), newSSL)
} }

Loading…
Cancel
Save