You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/en/docs/reference/access-authn-authz/certificate-signing-requests.md
+99-70Lines changed: 99 additions & 70 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,17 +21,16 @@ A CertificateSigningRequest (CSR) resource is used to request that a certificate
21
21
by a denoted signer, after which the request may be approved or denied before
22
22
finally being signed.
23
23
24
-
25
-
26
24
<!-- body -->
25
+
27
26
## Request signing process
28
27
29
-
The _CertificateSigningRequest_ resource type allows a client to ask for an X.509 certificate
28
+
The CertificateSigningRequest resource type allows a client to ask for an X.509 certificate
30
29
be issued, based on a signing request.
31
30
The CertificateSigningRequest object includes a PEM-encoded PKCS#10 signing request in
32
-
the `spec.request` field. The CertificateSigningRequest denotes the _signer_ (the
31
+
the `spec.request` field. The CertificateSigningRequest denotes the signer (the
33
32
recipient that the request is being made to) using the `spec.signerName` field.
34
-
Note that `spec.signerName` is a required key after api version `certificates.k8s.io/v1`.
33
+
Note that `spec.signerName` is a required key after API version `certificates.k8s.io/v1`.
35
34
36
35
Once created, a CertificateSigningRequest must be approved before it can be signed.
37
36
Depending on the signer selected, a CertificateSigningRequest may be automatically approved
@@ -68,54 +67,69 @@ This includes:
68
67
1.**Permitted subjects**: any restrictions on and behavior when a disallowed subject is requested.
69
68
1.**Permitted x509 extensions**: including IP subjectAltNames, DNS subjectAltNames, Email subjectAltNames, URI subjectAltNames etc, and behavior when a disallowed extension is requested.
70
69
1.**Permitted key usages / extended key usages**: any restrictions on and behavior when usages different than the signer-determined usages are specified in the CSR.
71
-
1.**Expiration/certificate lifetime**: whether it is fixed by the signer, configurable by the admin, determined by the CSR object etc and the behavior when an expiration is different than the signer-determined expiration that is specified in the CSR.
70
+
1.**Expiration/certificate lifetime**: whether it is fixed by the signer, configurable by the admin, determined by the CSR object etc
71
+
and the behavior when an expiration is different than the signer-determined expiration that is specified in the CSR.
72
72
1.**CA bit allowed/disallowed**: and behavior if a CSR contains a request a for a CA certificate when the signer does not permit it.
73
73
74
-
Commonly, the `status.certificate` field contains a single PEM-encoded X.509 certificate once the CSR is approved and the certificate is issued. Some signers store multiple certificates into the `status.certificate` field. In that case, the documentation for the signer should specify the meaning of additional certificates; for example, this might be the certificate plus intermediates to be presented during TLS handshakes.
74
+
Commonly, the `status.certificate` field contains a single PEM-encoded X.509
75
+
certificate once the CSR is approved and the certificate is issued. Some
76
+
signers store multiple certificates into the `status.certificate` field. In
77
+
that case, the documentation for the signer should specify the meaning of
78
+
additional certificates; for example, this might be the certificate plus
79
+
intermediates to be presented during TLS handshakes.
75
80
76
81
### Kubernetes signers
77
82
78
83
Kubernetes provides built-in signers that each have a well-known `signerName`:
79
84
80
-
1.`kubernetes.io/kube-apiserver-client`: signs certificates that will be honored as client-certs by the kube-apiserver.
81
-
Never auto-approved by {{< glossary_tooltip term_id="kube-controller-manager" >}}.
82
-
1. Trust distribution: signed certificates must be honored as client-certificates by the kube-apiserver. The CA bundle is not distributed by any other means.
83
-
1. Permitted subjects - no subject restrictions, but approvers and signers may choose not to approve or sign. Certain subjects like cluster-admin level users or groups vary between distributions and installations, but deserve additional scrutiny before approval and signing. The `CertificateSubjectRestriction` admission plugin is available and enabled by default to restrict `system:masters`, but it is often not the only cluster-admin subject in a cluster.
85
+
1.`kubernetes.io/kube-apiserver-client`: signs certificates that will be honored as client certificates by the API server.
86
+
Never auto-approved by {{< glossary_tooltip term_id="kube-controller-manager" >}}.
87
+
1. Trust distribution: signed certificates must be honored as client certificates by the API server. The CA bundle is not distributed by any other means.
88
+
1. Permitted subjects - no subject restrictions, but approvers and signers may choose not to approve or sign.
89
+
Certain subjects like cluster-admin level users or groups vary between distributions and installations,
90
+
but deserve additional scrutiny before approval and signing.
91
+
The `CertificateSubjectRestriction` admission plugin is enabled by default to restrict `system:masters`,
92
+
but it is often not the only cluster-admin subject in a cluster.
84
93
1. Permitted x509 extensions - honors subjectAltName and key usage extensions and discards other extensions.
85
-
1. Permitted key usages - must include []string{"client auth"}. Must not include key usages beyond []string{"digital signature", "key encipherment", "client auth"}
86
-
1. Expiration/certificate lifetime - minimum of CSR signer or request. The signer is responsible for checking that the certificate lifetime is valid and permissible.
94
+
1. Permitted key usages - must include `["client auth"]`. Must not include key usages beyond `["digital signature", "key encipherment", "client auth"]`.
95
+
1. Expiration/certificate lifetime - minimum of CSR signer or request.
96
+
The signer is responsible for checking that the certificate lifetime is valid and permissible.
87
97
1. CA bit allowed/disallowed - not allowed.
88
98
89
-
1.`kubernetes.io/kube-apiserver-client-kubelet`: signs client certificates that will be honored as client-certs by the
90
-
kube-apiserver.
91
-
May be auto-approved by {{< glossary_tooltip term_id="kube-controller-manager" >}}.
92
-
1. Trust distribution: signed certificates must be honored as client-certificates by the kube-apiserver. The CA bundle
99
+
1.`kubernetes.io/kube-apiserver-client-kubelet`: signs client certificates that will be honored as client certificates by the
100
+
API server.
101
+
May be auto-approved by {{< glossary_tooltip term_id="kube-controller-manager" >}}.
102
+
1. Trust distribution: signed certificates must be honored as clientcertificates by the API server. The CA bundle
93
103
is not distributed by any other means.
94
-
1. Permitted subjects - organizations are exactly `[]string{"system:nodes"}`, common name starts with `"system:node:"`
104
+
1. Permitted subjects - organizations are exactly `["system:nodes"]`, common name starts with "`system:node:`".
95
105
1. Permitted x509 extensions - honors key usage extensions, forbids subjectAltName extensions and drops other extensions.
1. Expiration/certificate lifetime - minimum of CSR signer or request. The signer is responsible for checking that the certificate lifetime is valid and permissible.
1. Expiration/certificate lifetime - minimum of CSR signer or request.
108
+
The signer is responsible for checking that the certificate lifetime is valid and permissible.
98
109
1. CA bit allowed/disallowed - not allowed.
99
110
100
111
1.`kubernetes.io/kubelet-serving`: signs serving certificates that are honored as a valid kubelet serving certificate
101
-
by the kube-apiserver, but has no other guarantees.
102
-
Never auto-approved by {{< glossary_tooltip term_id="kube-controller-manager" >}}.
103
-
1. Trust distribution: signed certificates must be honored by the kube-apiserver as valid to terminate connections to a kubelet. The CA bundle is not distributed by any other means.
104
-
1. Permitted subjects - organizations are exactly `[]string{"system:nodes"}`, common name starts with `"system:node:"`
105
-
1. Permitted x509 extensions - honors key usage and DNSName/IPAddress subjectAltName extensions, forbids EmailAddress and URI subjectAltName extensions, drops other extensions. At least one DNS or IP subjectAltName must be present.
1. Expiration/certificate lifetime - minimum of CSR signer or request.
108
121
1. CA bit allowed/disallowed - not allowed.
109
122
110
123
1.`kubernetes.io/legacy-unknown`: has no guarantees for trust at all. Some third-party distributions of Kubernetes
111
-
may honor client certificates signed by it. The stable CertificateSigningRequest API (version `certificates.k8s.io/v1` and later)
112
-
does not allow to set the `signerName` as `kubernetes.io/legacy-unknown`.
113
-
Never auto-approved by {{< glossary_tooltip term_id="kube-controller-manager" >}}.
114
-
1. Trust distribution: None. There is no standard trust or distribution for this signer in a Kubernetes cluster.
124
+
may honor client certificates signed by it. The stable CertificateSigningRequest API (version `certificates.k8s.io/v1` and later)
125
+
does not allow to set the `signerName` as `kubernetes.io/legacy-unknown`.
126
+
Never auto-approved by {{< glossary_tooltip term_id="kube-controller-manager" >}}.
127
+
1. Trust distribution: None. There is no standard trust or distribution for this signer in a Kubernetes cluster.
115
128
1. Permitted subjects - any
116
129
1. Permitted x509 extensions - honors subjectAltName and key usage extensions and discards other extensions.
117
130
1. Permitted key usages - any
118
-
1. Expiration/certificate lifetime - minimum of CSR signer or request. The signer is responsible for checking that the certificate lifetime is valid and permissible.
131
+
1. Expiration/certificate lifetime - minimum of CSR signer or request.
132
+
The signer is responsible for checking that the certificate lifetime is valid and permissible.
119
133
1. CA bit allowed/disallowed - not allowed.
120
134
121
135
{{< note >}}
@@ -126,7 +140,7 @@ Distribution of trust happens out of band for these signers. Any trust outside
126
140
coincidental. For instance, some distributions may honor `kubernetes.io/legacy-unknown` as client certificates for the
127
141
kube-apiserver, but this is not a standard.
128
142
None of these usages are related to ServiceAccount token secrets `.data[ca.crt]` in any way. That CA bundle is only
129
-
guaranteed to verify a connection to the kube-apiserver using the default service (`kubernetes.default.svc`).
143
+
guaranteed to verify a connection to the API server using the default service (`kubernetes.default.svc`).
130
144
131
145
## Authorization
132
146
@@ -156,24 +170,30 @@ To allow signing a CertificateSigningRequest:
A few steps are required in order to get normal user to be able to authenticate and invoke an API. First, this user must have certificate issued by the Kubernetes Cluster, and then present that Certificate to the API call as the Certificate Header or through the kubectl.
175
+
A few steps are required in order to get a normal user to be able to
176
+
authenticate and invoke an API. First, this user must have certificate issued
177
+
by the Kubernetes cluster, and then present that Certificate to the API call
178
+
as the Certificate Header or through the kubectl.
162
179
163
-
### Create Private Key
180
+
### Create private key
164
181
165
-
The following scripts show how to generate PKI private key and CSR. It is important to set CN and O attribute of the CSR. CN is the name of the user and O is the group that this user will belong to. You can refer to [RBAC](/docs/reference/access-authn-authz/rbac/) for standard groups.
182
+
The following scripts show how to generate PKI private key and CSR. It is
183
+
important to set CN and O attribute of the CSR. CN is the name of the user and
184
+
O is the group that this user will belong to. You can refer to
185
+
[RBAC](/docs/reference/access-authn-authz/rbac/) for standard groups.
166
186
167
-
```
187
+
```shell
168
188
openssl genrsa -out john.key 2048
169
189
openssl req -new -key john.key -out john.csr
170
190
```
171
191
172
-
### Create Certificate Request Kubernetes Object
192
+
### Create CertificateSigningRequest
173
193
174
194
Create a CertificateSigningRequest and submit it to a Kubernetes Cluster via kubectl. Below is a script to generate the CertificateSigningRequest.
175
195
176
-
```
196
+
```shell
177
197
cat <<EOF | kubectl apply -f -
178
198
apiVersion: certificates.k8s.io/v1
179
199
kind: CertificateSigningRequest
@@ -191,68 +211,78 @@ EOF
191
211
192
212
Some points to note:
193
213
194
-
- usage has to be 'client auth'
195
-
- request is the base64 encoded value of the CSR file content. You can use this command to get that ```cat john.csr | base64 | tr -d "\n"```
214
+
-`usages` has to be '`client auth`'
215
+
-`request` is the base64 encoded value of the CSR file content.
216
+
You can get the content using this command: ```cat john.csr | base64 | tr -d "\n"```
196
217
197
-
### Approve Certificate Request
218
+
### Approve certificate signing request
198
219
199
220
Use kubectl to create a CSR and approve it.
200
221
201
-
Get the list of CSRs
202
-
```
222
+
Get the list of CSRs:
223
+
224
+
```shell
203
225
kubectl get csr
204
226
```
205
227
206
-
Approve the CSR
207
-
```
228
+
Approve the CSR:
229
+
230
+
```shell
208
231
kubectl certificate approve john
209
232
```
210
233
211
-
### Get the Certificate
234
+
### Get the certificate
212
235
213
-
Retrieve the Certificate from the CSR.
236
+
Retrieve the certificate from the CSR:
214
237
215
-
```
238
+
```shell
216
239
kubectl get csr/john -o yaml
217
240
```
218
241
219
-
The Certificate value is in Base64-encoded format under status.certificate.
242
+
The certificate value is in Base64-encoded format under `status.certificate`.
220
243
221
-
### Create Role and Role Binding
244
+
### Create Role and RoleBinding
222
245
223
-
You get the Certificate already. Now it is time to define the Role and Role Binding for this user to access Kubernetes Cluster resources.
246
+
With the certificate created. it is time to define the Role and RoleBinding for
247
+
this user to access Kubernetes cluster resources.
224
248
225
-
This is a sample script to create role for this new user
226
-
```
249
+
This is a sample script to create a Role for this new user:
250
+
251
+
```shell
227
252
kubectl create role developer --verb=create --verb=get --verb=list --verb=update --verb=delete --resource=pods
228
253
```
229
254
230
-
This is a sample script to create role binding for this new user
231
-
```
255
+
This is a sample command to create a RoleBinding for this new user:
### Approval & rejection using the Kubernetes API {#approval-rejection-api-client}
313
+
### Approval or rejection using the Kubernetes API {#approval-rejection-api-client}
284
314
285
315
Users of the REST API can approve CSRs by submitting an UPDATE request to the `approval`
286
316
subresource of the CSR to be approved. For example, you could write an
@@ -329,7 +359,8 @@ you like. If you want to add a note just for human consumption, use the
329
359
330
360
### Control plane signer {#signer-control-plane}
331
361
332
-
The Kubernetes control plane implements each of the [Kubernetes signers](/docs/reference/access-authn-authz/certificate-signing-requests/#kubernetes-signers),
362
+
The Kubernetes control plane implements each of the
* Read [Manage TLS Certificates in a Cluster](/docs/tasks/tls/managing-tls-in-a-cluster/)
398
426
* View the source code for the kube-controller-manager built in [signer](https://github.com/kubernetes/kubernetes/blob/32ec6c212ec9415f604ffc1f4c1f29b782968ff1/pkg/controller/certificates/signer/cfssl_signer.go)
399
427
* View the source code for the kube-controller-manager built in [approver](https://github.com/kubernetes/kubernetes/blob/32ec6c212ec9415f604ffc1f4c1f29b782968ff1/pkg/controller/certificates/approver/sarapprove.go)
400
428
* For details of X.509 itself, refer to [RFC 5280](https://tools.ietf.org/html/rfc5280#section-3.1) section 3.1
401
429
* For information on the syntax of PKCS#10 certificate signing requests, refer to [RFC 2986](https://tools.ietf.org/html/rfc2986)
0 commit comments