22title : Configuring `step-ca` Templates
33html_title : Configuring open source step-ca Templates
44description : Learn how to configure step-ca Templates
5+ updated_at : March 26, 2025
56---
67
78People use private CAs for all sorts of things, in many different contexts:
@@ -126,7 +127,7 @@ The following snippet shows a provisioner with custom X.509 and SSH templates:
126127 - ** _ relative to the execution directory of ` step-ca ` _ ** : e.g. ` ./path/to/file.tpl ` or ` ../path/to/file.tpl `
127128
128129 - ** templateData** : defines variables that can be used in the template.
129- In the example above, you will be able to use the defined organizational unit as the variable ` {{ .OrganizationalUnit }} ` ,
130+ In the example above, you are able to use the defined organizational unit as the variable ` {{ .OrganizationalUnit }} ` ,
130131 for example in a template like:
131132
132133 ``` json
@@ -212,21 +213,23 @@ See [the complete list of fields supported in `step-ca` templates](https://githu
212213 In templates, some variables are prefixed with <code >.Insecure</code >.
213214 They contain information that has not been cryptographically signed
214215 by a source that the CA trusts.
215- For example, the <code >.Insecure.CR</code > variable holds the user-supplied Certificate Request.
216+ For example, the <code >.Insecure.CR</code > map holds the user-supplied Certificate Request.
216217 </div >
217218</Alert >
218219
219- Here are some common variables available in X.509 certificate templates:
220+ Here are some variables available in X.509 certificate templates:
220221
221222- ** .Subject** :
222- This is the subject that was passed in to ` step certificate ` or ` step ca certificate ` . Specifically,
223- ` .Subject.CommonName ` contains the Common Name for the certificate.
223+ The subject that was passed in to ` step certificate ` or ` step ca certificate ` . Specifically,
224+ ` .Subject.CommonName ` contains the Common Name for the certificate. By default, a passed-in subject
225+ value must match a value from a trusted source in order to be added to the certificate.
224226
225227- ** .SANs** :
226228 Subject Alternative Names.
227229 This is a list of maps containing SANs for the certificate.
228230 Unless SANs are specified (using the ` --san ` flag, for example),
229- the ` .Subject.CommonName ` is the default SAN.
231+ the ` .Subject.CommonName ` is the default SAN. By default, a passed-in subject
232+ value must match a value from a trusted source in order to be added to the certificate.
230233
231234- ** .Token** :
232235 If a signed token was used to obtain the certificate
@@ -244,6 +247,8 @@ Here are some common variables available in X.509 certificate templates:
244247 this is an array of the certificate chain from the request.
245248 This chain connects the authorization certificate to the root CA configured in the provisioner.
246249
250+ - ** .Insecure** These variables are marked insecure because they contain client-supplied data that is not signed by a trusted party.
251+
247252- ** .Insecure.CR** <Reference id = " star11" marker = " *" />: ☠️
248253 This holds the Certificate Request (CSR) received from the client.
249254 ` .Insecure.CR ` is a [ ` crypto/x509 ` CertificateRequest] ( https://pkg.go.dev/crypto/x509#CertificateRequest ) .
@@ -384,7 +389,7 @@ For more details on ASN.1 types and their meanings, see [ASN.1 Types](https://ww
384389
385390#### asn1Marshal
386391
387- ` asn1Marshal ` simplifies the encoding of Go variables into ASN.1.
392+ ` asn1Marshal ` simplifies the encoding of Go values into ASN.1.
388393For example, if you want to encode the Not After value in an X5C authorization certificate,
389394without converting it to a string first, ` asn1Marshal .AuthorizationCrt.NotAfter ` will do the trick.
390395
@@ -706,21 +711,21 @@ certificate subject on `step-ca` if a template is provided in the `ca.json`, and
706711it will set the Subject Alternative Name extension to critical if the subject is
707712empty.
708713
709- #### User-Provided Variables in Signing Requests
714+ #### User-Provided Values in Signing Requests
710715
711- In ` step-ca ` , X.509 templates can also be parameterized with variables that will be
716+ In ` step-ca ` , X.509 templates can also be parameterized with values
712717provided by ` step ` at certificate creation time. A common use case for
713- variables is when you receive a CSR from another team, or a CSR embedded in
718+ values is when you receive a CSR from another team, or a CSR embedded in
714719hardware, and you need to define a SAN for it.
715720
716- For example, below is an X.509 template that accepts the user variable ` dnsName `
717- but falls back to the default leaf template if it's not present:
721+ For example, below is an X.509 template that accepts the user-supplied value ` dnsName `
722+ but it falls back to the default leaf template value if it's not present:
718723
719724``` json
720725{
721726 "subject" : {{ toJson .Subject }},
722727{{- if .Insecure.User.dnsName }}
723- "dnsNames" : {{ toJson .Insecure.User.dnsName }},
728+ "dnsNames" : {{ toJson .Insecure.User.dnsName }},
724729{{- else }}
725730 "sans" : {{ toJson .SANs }},
726731{{- end }}
@@ -743,13 +748,13 @@ $ step ca sign --set-file vars.json input.csr output.crt
743748```
744749
745750Both flags, ` --set <name=value> ` and ` --set-file <path> ` are available in
746- [ ` step ca certificate ` ] ( ../step-cli/reference/ca/certificate ) and [ ` step ca sign ` ] ( ../step-cli/reference/ca/sign ) . If you need to pass more than one
747- variable, you can use ` --set ` multiple times or use a JSON file with multiple
748- properties.
751+ [ ` step ca certificate ` ] ( ../step-cli/reference/ca/certificate ) and [ ` step ca sign ` ] ( ../step-cli/reference/ca/sign ) .
752+ If you need to pass more than one value,
753+ you can use ` --set ` multiple times or use a JSON file with multiple properties.
749754
750755It's worth mentioning the while we used ` "dnsNames" ` instead of ` "sans" ` in the example above, both can
751- be used. ` "dnsNames" ` is an array of strings (or just one string if only one is
752- required), while ` "sans" ` is an array of objects like :
756+ be used. ` "dnsNames" ` is a list of strings (or just one string if only one is
757+ required), while ` "sans" ` is an list of maps :
753758
754759``` json
755760[
@@ -760,8 +765,8 @@ required), while `"sans"` is an array of objects like:
760765]
761766```
762767
763- The variable ` .SANs ` is generated by the provisioners with the values of the
764- trusted names.
768+ The list ` .SANs ` is generated by the provisioner,
769+ containing the values of the trusted names.
765770
766771Besides ` "dnsNames" ` , you can also use ` "emailAddresses" ` , ` "ipAddresses" ` , and
767772` "uris" ` .
0 commit comments