From 869eb618ea3867387f6d7cd8b3d4ce615144274c Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Wed, 1 Jun 2016 10:40:58 +0200 Subject: Add mailAttr into CSR tmpl --- crypto.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'crypto.go') diff --git a/crypto.go b/crypto.go index 917149d..5f6cf34 100644 --- a/crypto.go +++ b/crypto.go @@ -98,9 +98,21 @@ func NewKey(size int) (crypto.PrivateKey, error) { var oidMailAddress = asn1.ObjectIdentifier{1, 2, 840, 113549, 1, 9, 1} +func mailAttr(mail string) pkix.AttributeTypeAndValue { + return pkix.AttributeTypeAndValue{ + Type: oidMailAddress, + Value: mail, + } +} + func NewCSR(key crypto.PrivateKey, altnames, emails []string) (string, error) { + mail := mailAttr(emails[0]) + subj := pkix.Name{ + CommonName: altnames[0], + Names: []pkix.AttributeTypeAndValue{mail}, + } tmpl := x509.CertificateRequest{ - Subject: pkix.Name{CommonName: altnames[0]}, + Subject: subj, DNSNames: altnames, EmailAddresses: emails, } -- cgit v1.2.3