aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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,
}