aboutsummaryrefslogtreecommitdiff
path: root/crypto.go
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-03-18 17:08:47 +0100
committerDimitri Sokolyuk <demon@dim13.org>2016-03-18 17:08:47 +0100
commit40a9ef230ee6112e6e8bf5981a4e18a17f34e307 (patch)
tree69338560fe2a6085abcd773aceca5eda82e5c3c4 /crypto.go
parent67e61eb82fe9fcb69f47037a1a4917dc9cfdd777 (diff)
Add emails to CSR
Diffstat (limited to 'crypto.go')
-rw-r--r--crypto.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/crypto.go b/crypto.go
index f6aad30..a8ecb41 100644
--- a/crypto.go
+++ b/crypto.go
@@ -93,13 +93,16 @@ func NewKey(size int) (crypto.PrivateKey, error) {
}
}
-func NewCSR(key crypto.PrivateKey, altnames []string) (string, error) {
+func NewCSR(key crypto.PrivateKey, altnames, emails []string) (string, error) {
tmpl := x509.CertificateRequest{
Subject: pkix.Name{CommonName: altnames[0]},
}
if len(altnames) > 1 {
tmpl.DNSNames = altnames
}
+ if len(emails) > 1 {
+ tmpl.EmailAddresses = emails
+ }
der, err := x509.CreateCertificateRequest(rand.Reader, &tmpl, key)
if err != nil {
return "", err