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

Commit

Permalink
Merge pull request #7 from orbitalturtle/certificateprovider-multi
Browse files Browse the repository at this point in the history
Add support to CSR for multiple domains
  • Loading branch information
gkrizek authored Apr 12, 2021
2 parents edc3933 + f31dedc commit bc314c1
Showing 1 changed file with 15 additions and 0 deletions.
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

0 comments on commit bc314c1

Please sign in to comment.