Skip to content

Commit 495f491

Browse files
privateca: update certificate authority samples with more realistic values (#12259) (#20222)
[upstream:27812e087aaf4250c076b5d572b3934c1a013e2e] Signed-off-by: Modular Magician <magic-modules@google.com>
1 parent 19a78a7 commit 495f491

File tree

3 files changed

+35
-101
lines changed

3 files changed

+35
-101
lines changed

.changelog/12259.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
```release-note:none
2+
```

google/services/privateca/resource_privateca_certificate_authority_generated_test.go

Lines changed: 15 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -70,40 +70,28 @@ resource "google_privateca_certificate_authority" "default" {
7070
config {
7171
subject_config {
7272
subject {
73-
organization = "HashiCorp"
73+
organization = "ACME"
7474
common_name = "my-certificate-authority"
7575
}
76-
subject_alt_name {
77-
dns_names = ["hashicorp.com"]
78-
}
7976
}
8077
x509_config {
8178
ca_options {
79+
# is_ca *MUST* be true for certificate authorities
8280
is_ca = true
83-
max_issuer_path_length = 10
8481
}
8582
key_usage {
8683
base_key_usage {
87-
digital_signature = true
88-
content_commitment = true
89-
key_encipherment = false
90-
data_encipherment = true
91-
key_agreement = true
84+
# cert_sign and crl_sign *MUST* be true for certificate authorities
9285
cert_sign = true
9386
crl_sign = true
94-
decipher_only = true
9587
}
9688
extended_key_usage {
97-
server_auth = true
98-
client_auth = false
99-
email_protection = true
100-
code_signing = true
101-
time_stamping = true
10289
}
10390
}
10491
}
10592
}
106-
lifetime = "86400s"
93+
# valid for 10 years
94+
lifetime = "${10 * 365 * 24 * 3600}s"
10795
key_spec {
10896
algorithm = "RSA_PKCS1_4096_SHA256"
10997
}
@@ -149,12 +137,9 @@ resource "google_privateca_certificate_authority" "root-ca" {
149137
config {
150138
subject_config {
151139
subject {
152-
organization = "HashiCorp"
140+
organization = "ACME"
153141
common_name = "my-certificate-authority"
154142
}
155-
subject_alt_name {
156-
dns_names = ["hashicorp.com"]
157-
}
158143
}
159144
x509_config {
160145
ca_options {
@@ -168,7 +153,6 @@ resource "google_privateca_certificate_authority" "root-ca" {
168153
crl_sign = true
169154
}
170155
extended_key_usage {
171-
server_auth = false
172156
}
173157
}
174158
}
@@ -196,43 +180,33 @@ resource "google_privateca_certificate_authority" "default" {
196180
config {
197181
subject_config {
198182
subject {
199-
organization = "HashiCorp"
183+
organization = "ACME"
200184
common_name = "my-subordinate-authority"
201185
}
202-
subject_alt_name {
203-
dns_names = ["hashicorp.com"]
204-
}
205186
}
206187
x509_config {
207188
ca_options {
208189
is_ca = true
209-
# Force the sub CA to only issue leaf certs
210-
max_issuer_path_length = 0
190+
# Force the sub CA to only issue leaf certs.
191+
# Use e.g.
192+
# max_issuer_path_length = 1
193+
# if you need to chain more subordinates.
194+
zero_max_issuer_path_length = true
211195
}
212196
key_usage {
213197
base_key_usage {
214-
digital_signature = true
215-
content_commitment = true
216-
key_encipherment = false
217-
data_encipherment = true
218-
key_agreement = true
219198
cert_sign = true
220199
crl_sign = true
221-
decipher_only = true
222200
}
223201
extended_key_usage {
224-
server_auth = true
225-
client_auth = false
226-
email_protection = true
227-
code_signing = true
228-
time_stamping = true
229202
}
230203
}
231204
}
232205
}
233-
lifetime = "86400s"
206+
# valid for 5 years
207+
lifetime = "${5 * 365 * 24 * 3600}s"
234208
key_spec {
235-
algorithm = "RSA_PKCS1_4096_SHA256"
209+
algorithm = "RSA_PKCS1_2048_SHA256"
236210
}
237211
type = "SUBORDINATE"
238212
}

website/docs/r/privateca_certificate_authority.html.markdown

Lines changed: 18 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -52,40 +52,28 @@ resource "google_privateca_certificate_authority" "default" {
5252
config {
5353
subject_config {
5454
subject {
55-
organization = "HashiCorp"
55+
organization = "ACME"
5656
common_name = "my-certificate-authority"
5757
}
58-
subject_alt_name {
59-
dns_names = ["hashicorp.com"]
60-
}
6158
}
6259
x509_config {
6360
ca_options {
61+
# is_ca *MUST* be true for certificate authorities
6462
is_ca = true
65-
max_issuer_path_length = 10
6663
}
6764
key_usage {
6865
base_key_usage {
69-
digital_signature = true
70-
content_commitment = true
71-
key_encipherment = false
72-
data_encipherment = true
73-
key_agreement = true
66+
# cert_sign and crl_sign *MUST* be true for certificate authorities
7467
cert_sign = true
7568
crl_sign = true
76-
decipher_only = true
7769
}
7870
extended_key_usage {
79-
server_auth = true
80-
client_auth = false
81-
email_protection = true
82-
code_signing = true
83-
time_stamping = true
8471
}
8572
}
8673
}
8774
}
88-
lifetime = "86400s"
75+
# valid for 10 years
76+
lifetime = "${10 * 365 * 24 * 3600}s"
8977
key_spec {
9078
algorithm = "RSA_PKCS1_4096_SHA256"
9179
}
@@ -107,12 +95,9 @@ resource "google_privateca_certificate_authority" "root-ca" {
10795
config {
10896
subject_config {
10997
subject {
110-
organization = "HashiCorp"
98+
organization = "ACME"
11199
common_name = "my-certificate-authority"
112100
}
113-
subject_alt_name {
114-
dns_names = ["hashicorp.com"]
115-
}
116101
}
117102
x509_config {
118103
ca_options {
@@ -126,7 +111,6 @@ resource "google_privateca_certificate_authority" "root-ca" {
126111
crl_sign = true
127112
}
128113
extended_key_usage {
129-
server_auth = false
130114
}
131115
}
132116
}
@@ -154,43 +138,33 @@ resource "google_privateca_certificate_authority" "default" {
154138
config {
155139
subject_config {
156140
subject {
157-
organization = "HashiCorp"
141+
organization = "ACME"
158142
common_name = "my-subordinate-authority"
159143
}
160-
subject_alt_name {
161-
dns_names = ["hashicorp.com"]
162-
}
163144
}
164145
x509_config {
165146
ca_options {
166147
is_ca = true
167-
# Force the sub CA to only issue leaf certs
168-
max_issuer_path_length = 0
148+
# Force the sub CA to only issue leaf certs.
149+
# Use e.g.
150+
# max_issuer_path_length = 1
151+
# if you need to chain more subordinates.
152+
zero_max_issuer_path_length = true
169153
}
170154
key_usage {
171155
base_key_usage {
172-
digital_signature = true
173-
content_commitment = true
174-
key_encipherment = false
175-
data_encipherment = true
176-
key_agreement = true
177156
cert_sign = true
178157
crl_sign = true
179-
decipher_only = true
180158
}
181159
extended_key_usage {
182-
server_auth = true
183-
client_auth = false
184-
email_protection = true
185-
code_signing = true
186-
time_stamping = true
187160
}
188161
}
189162
}
190163
}
191-
lifetime = "86400s"
164+
# valid for 5 years
165+
lifetime = "${5 * 365 * 24 * 3600}s"
192166
key_spec {
193-
algorithm = "RSA_PKCS1_4096_SHA256"
167+
algorithm = "RSA_PKCS1_2048_SHA256"
194168
}
195169
type = "SUBORDINATE"
196170
}
@@ -238,7 +212,6 @@ resource "google_privateca_certificate_authority" "default" {
238212
ca_options {
239213
# is_ca *MUST* be true for certificate authorities
240214
is_ca = true
241-
max_issuer_path_length = 10
242215
}
243216
key_usage {
244217
base_key_usage {
@@ -247,7 +220,6 @@ resource "google_privateca_certificate_authority" "default" {
247220
crl_sign = true
248221
}
249222
extended_key_usage {
250-
server_auth = false
251223
}
252224
}
253225
name_constraints {
@@ -284,43 +256,29 @@ resource "google_privateca_certificate_authority" "default" {
284256
config {
285257
subject_config {
286258
subject {
287-
organization = "HashiCorp"
259+
organization = "ACME"
288260
common_name = "my-certificate-authority"
289261
}
290-
subject_alt_name {
291-
dns_names = ["hashicorp.com"]
292-
}
293262
}
294263
subject_key_id {
295264
key_id = "4cf3372289b1d411b999dbb9ebcd44744b6b2fca"
296265
}
297266
x509_config {
298267
ca_options {
299268
is_ca = true
300-
max_issuer_path_length = 10
301269
}
302270
key_usage {
303271
base_key_usage {
304-
digital_signature = true
305-
content_commitment = true
306-
key_encipherment = false
307-
data_encipherment = true
308-
key_agreement = true
309272
cert_sign = true
310273
crl_sign = true
311-
decipher_only = true
312274
}
313275
extended_key_usage {
314-
server_auth = true
315-
client_auth = false
316-
email_protection = true
317-
code_signing = true
318-
time_stamping = true
319276
}
320277
}
321278
}
322279
}
323-
lifetime = "86400s"
280+
# valid for 10 years
281+
lifetime = "${10 * 365 * 24 * 3600}s"
324282
key_spec {
325283
cloud_kms_key_version = "projects/keys-project/locations/us-central1/keyRings/key-ring/cryptoKeys/crypto-key/cryptoKeyVersions/1"
326284
}

0 commit comments

Comments
 (0)