From 85f32491cb09216db70a44dd7fae05b128586f09 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Wed, 9 Sep 2020 12:01:04 -0700 Subject: [PATCH] Add dumb hook to set the organization in the client cert --- factory/cert_utils.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/factory/cert_utils.go b/factory/cert_utils.go index 6b28abe..2cab0f9 100644 --- a/factory/cert_utils.go +++ b/factory/cert_utils.go @@ -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