aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2016-06-01 10:40:58 +0200
committerDimitri Sokolyuk <demon@dim13.org>2016-06-01 10:40:58 +0200
commit869eb618ea3867387f6d7cd8b3d4ce615144274c (patch)
treee46e29f9bd104064e1f78b334d89413864ac6b5d
parentfde9147075fc39ca5849e50b95b7879c4c8d2c93 (diff)
Add mailAttr into CSR tmpl
-rw-r--r--crypto.go14
1 files changed, 13 insertions, 1 deletions
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,
}