Add dumb hook to set the organization in the client cert

This commit is contained in:
Darren Shepherd 2020-09-09 12:01:04 -07:00
parent ebebb82b9b
commit 85f32491cb

View File

@ -10,6 +10,7 @@ import (
"math"
"math/big"
"net"
"strings"
"time"
)
@ -57,6 +58,12 @@ func NewSignedClientCert(signer crypto.Signer, caCert *x509.Certificate, caKey c
},
}
parts := strings.Split(cn, ",o=")
if len(parts) > 1 {
parent.Subject.CommonName = parts[0]
parent.Subject.Organization = parts[1:]
}
cert, err := x509.CreateCertificate(rand.Reader, &parent, caCert, signer.Public(), caKey)
if err != nil {
return nil, err