Skip to content
This repository has been archived by the owner on Jun 25, 2024. It is now read-only.

Add support to CSR for multiple domains #7

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions certprovider/zerossl.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@ func ZeroSSLGenerateCsr(keyBytes []byte, domain string) (csrBuffer bytes.Buffer,
if err != nil {
return csrBuffer, err
}

// If there's more than one domain, turn it into a slice for procesing.
domains := make([]string, 0)
multi_domains := false
if strings.ContainsAny(domain, ",") {
multi_domains = true
domains = strings.Split(domain, ",")
domain = domains[0]
}

subj := pkix.Name{
CommonName: domain,
}
Expand All @@ -82,6 +92,11 @@ func ZeroSSLGenerateCsr(keyBytes []byte, domain string) (csrBuffer bytes.Buffer,
RawSubject: asn1Subj,
SignatureAlgorithm: x509.SHA256WithRSA,
}

if multi_domains {
template.DNSNames = domains[1:]
}

csrBytes, err := x509.CreateCertificateRequest(rand.Reader, &template, privKey)
if err != nil {
return csrBuffer, err
Expand Down