From 5930ea52f0311bde21a68895d72a84e3fbc1db4d Mon Sep 17 00:00:00 2001 From: xenolf Date: Tue, 15 Dec 2015 21:12:09 +0100 Subject: [PATCH] lib: make renew aware of SAN --- acme/client.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/acme/client.go b/acme/client.go index 714b22af..0fef85f3 100644 --- a/acme/client.go +++ b/acme/client.go @@ -368,7 +368,24 @@ func (c *Client) RenewCertificate(cert CertificateResource, revokeOld bool, bund return cert, nil } - newCerts, failures := c.ObtainCertificates([]string{cert.Domain}, bundle) + var domains []string + newCerts := make([]CertificateResource, 1) + var failures map[string]error + // check for SAN certificate + if len(x509Cert.DNSNames) > 1 { + domains = append(domains, x509Cert.Subject.CommonName) + for _, sanDomain := range x509Cert.DNSNames { + if sanDomain == x509Cert.Subject.CommonName { + continue + } + domains = append(domains, sanDomain) + newCerts[0], failures = c.ObtainSANCertificate(domains, bundle) + } + } else { + domains = append(domains, x509Cert.Subject.CommonName) + newCerts, failures = c.ObtainCertificates(domains, bundle) + } + if len(failures) > 0 { return CertificateResource{}, failures[cert.Domain] }