sprig
sprig copied to clipboard
Feature: extend genCA/genCAWithKey/genSignedCert/genSignedCertWithKey to support not only CN, but other fields as well
getCA, genSignedCert and friends right now support only CN field.
For some applications it's necessary to provide other parameters that pkix.Name supports [1].
E.g. I've tried to use Sprig to generate k8s CA and admin cert, but in openssl it's necessary to provide:
/CN=admin/O=system:masters, and it's not possible to generate k8s admin cert with sprig because of that.
I've created the Extended version of that functions [2]. If the parameter doesn't have / it behaves like the current implementation, but if the first symbol is / it tries to parse it as RFC 2253 Distinguished Names syntax similar to what
openssl does. Here is the implementation of the function that converts that [3].
Another option I was thinking about - instead of RFC 2253 format it's possible to unmarshal Name structure from some
format (e.g. yaml etc) and use it as a parameter.
If the Sprig community needs RFC 2253 implementation, I could create a PR based on the work I have already done. Please let me know.
Cheers! [1]
pkix.Name{
CommonName: `CN`,
SerialNumber: `SN`,
Country: []string{`C1`, `C2`},
Organization: []string{`O1`, `O2`},
OrganizationalUnit: []string{`OU1`, `OU2`},
Locality: []string{`L1`, `L2`},
Province: []string{`ST1`, `ST2`},
StreetAddress: []string{`S1`, `S2`},
PostalCode: []string{`PC1`, `PC2`},
[2] https://github.com/airshipit/airshipctl/blob/master/pkg/document/plugin/templater/extlib/crypto.go
[3] https://github.com/airshipit/airshipctl/blob/master/pkg/document/plugin/templater/extlib/crypto.go#L145