Skip to content

Commit 897b61b

Browse files
committed
Add a certificate policy example to the Templates docs
1 parent f080d14 commit 897b61b

File tree

1 file changed

+50
-8
lines changed

1 file changed

+50
-8
lines changed

step-ca/templates.mdx

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Configuring `step-ca` Templates
33
html_title: Configuring open source step-ca Templates
44
description: Learn how to configure step-ca Templates
5-
updated_at: March 26, 2025
5+
updated_at: April 02, 2025
66
---
77

88
People use private CAs for all sorts of things, in many different contexts:
@@ -861,16 +861,58 @@ also write a custom extension like:
861861

862862
```json
863863
{
864-
"extensions": [
865-
{"id": "1.2.3.4", "critical": false, "value": "Y3VzdG9tIGV4dGVuc2lvbiB2YWx1ZQ=="}
866-
]
864+
"extensions": [
865+
{"id": "1.2.3.4", "critical": false, "value": "Y3VzdG9tIGV4dGVuc2lvbiB2YWx1ZQ=="}
866+
]
867+
}
868+
```
869+
870+
The value of the extension is the Base64 encoding of the
871+
actual ASN.1 bytes that go into that extension.
872+
873+
For a more human-readable template,
874+
you can also use [ASN.1 functions](#asn1-values) in the extension `value` field.
875+
We'll do that in the next example.
876+
877+
#### Deep dive: Certificate Policies
878+
879+
X.509 Certificate Policies define policy constraints of a certificate.
880+
They help relying parties determine the trustworthiness of a certificate,
881+
and how to use it in practice.
882+
For example, a Certificate Policy might detail how the CA verified the identity of the certificate requestor,
883+
or elaborate on use cases (TLS, email encryption, code signing) that are allowed by the PKI for that certificate.
884+
885+
A Certificate Practice Statement (CPS) is type of policy that references a human-readable document published by a CA
886+
describing its operational practices and security controls.
887+
888+
Here's [an example of a CPS from Let's Encrypt](https://letsencrypt.org/documents/isrg-cp-cps-v5.7/).
889+
890+
Let's put together a Certificate Policies extension using an X.509 template.
891+
We'll need to construct some ASN.1 for this:
892+
893+
```
894+
{
895+
"extensions": [
896+
{
897+
"id": "2.5.29.32",
898+
"value": {{
899+
asn1Seq
900+
(asn1Seq
901+
(asn1Enc "oid:1.3.5.7")
902+
(asn1Seq (asn1Seq (asn1Enc "oid:1.3.6.1.5.5.7.2.1") (asn1Enc "ia5:http://example.com/cps")))
903+
)
904+
| toJson
905+
}}
906+
}
907+
]
867908
}
868909
```
869910

870-
The crux here is that the value of the extension is the Base64 encoding of the
871-
actual bytes that go into that extension, so if you are encoding a structure
872-
in your extension using the ASN.1 encoding, you will have to put the Base64
873-
version of the encoded bytes.
911+
First, the OID `2.5.29.32` represents the Certificate Policies extension.
912+
In the value for this extension, we have two policies.
913+
The first references Policy OID `1.3.5.7`, a custom policy OID that would be defined by the organization.
914+
For the second value, both a Policy OID and a CPS URI `http://example.com/cps` is provided.
915+
The CPS URI contains a document explaining how the CA enforces policy `1.3.6.1.5.5.7.2.1`.
874916

875917
#### X.509 OpenVPN certificates
876918

0 commit comments

Comments
 (0)