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

This commit is contained in:
zhengkunwang 2023-11-15 14:20:09 +08:00 committed by GitHub
parent dc51148a29
commit abaa42af88
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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)
} }