Skip to content

Allow a subject dict in certificate generation functions - #494

Open
aodinokov wants to merge 1 commit into
Masterminds:masterfrom
aodinokov:cert-subject-dict
Open

aodinokov wants to merge 1 commit into
Masterminds:masterfrom
aodinokov:cert-subject-dict

Conversation

@aodinokov

Copy link
Copy Markdown

The certificate functions only accept a common name, so certificates that need
other subject fields can't be generated. A common case is Kubernetes client
certificates, where the group comes from the Organization (e.g. the admin cert
needs O=system:masters). Helm chart authors can't create those with sprig today.

This lets the first argument of genCA, genSelfSignedCert, genSignedCert
and their WithKey variants be either a string (unchanged behavior) or a dict:

genSignedCert (dict "commonName" "admin" "organization" (list "system:masters")) nil nil 365 $ca

Supported keys map to pkix.Name: commonName, serialNumber, organization,
organizationalUnit, country, province, locality, streetAddress,
postalCode. List fields take a string or a list. Unknown keys return an error,
so a typo like organisation doesn't silently produce a cert without the group.

Existing templates are not affected. Tests and docs are included.

Closes #284

The first argument of genCA, genSelfSignedCert, genSignedCert and their
WithKey variants can now be a dict of subject fields (organization,
organizationalUnit, country, ...) in addition to a common name string.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: extend genCA/genCAWithKey/genSignedCert/genSignedCertWithKey to support not only CN, but other fields as well

1 participant