Skip to content

Commit 05228fb

Browse files
hoexteramanMahendroo
authored andcommitted
privateca: update certificate authority samples with more realistic values (GoogleCloudPlatform#12259)
Signed-off-by: Sven Hoexter <[email protected]>
1 parent bed7acc commit 05228fb

4 files changed

+18
-60
lines changed

mmv1/templates/terraform/examples/privateca_certificate_authority_basic.tf.tmpl

+5-17
Original file line numberDiff line numberDiff line change
@@ -8,40 +8,28 @@ resource "google_privateca_certificate_authority" "{{$.PrimaryResourceId}}" {
88
config {
99
subject_config {
1010
subject {
11-
organization = "HashiCorp"
11+
organization = "ACME"
1212
common_name = "my-certificate-authority"
1313
}
14-
subject_alt_name {
15-
dns_names = ["hashicorp.com"]
16-
}
1714
}
1815
x509_config {
1916
ca_options {
17+
# is_ca *MUST* be true for certificate authorities
2018
is_ca = true
21-
max_issuer_path_length = 10
2219
}
2320
key_usage {
2421
base_key_usage {
25-
digital_signature = true
26-
content_commitment = true
27-
key_encipherment = false
28-
data_encipherment = true
29-
key_agreement = true
22+
# cert_sign and crl_sign *MUST* be true for certificate authorities
3023
cert_sign = true
3124
crl_sign = true
32-
decipher_only = true
3325
}
3426
extended_key_usage {
35-
server_auth = true
36-
client_auth = false
37-
email_protection = true
38-
code_signing = true
39-
time_stamping = true
4027
}
4128
}
4229
}
4330
}
44-
lifetime = "86400s"
31+
# valid for 10 years
32+
lifetime = "${10 * 365 * 24 * 3600}s"
4533
key_spec {
4634
algorithm = "RSA_PKCS1_4096_SHA256"
4735
}

mmv1/templates/terraform/examples/privateca_certificate_authority_byo_key.tf.tmpl

-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ resource "google_privateca_certificate_authority" "{{$.PrimaryResourceId}}" {
3737
ca_options {
3838
# is_ca *MUST* be true for certificate authorities
3939
is_ca = true
40-
max_issuer_path_length = 10
4140
}
4241
key_usage {
4342
base_key_usage {
@@ -46,7 +45,6 @@ resource "google_privateca_certificate_authority" "{{$.PrimaryResourceId}}" {
4645
crl_sign = true
4746
}
4847
extended_key_usage {
49-
server_auth = false
5048
}
5149
}
5250
name_constraints {

mmv1/templates/terraform/examples/privateca_certificate_authority_custom_ski.tf.tmpl

+3-17
Original file line numberDiff line numberDiff line change
@@ -8,43 +8,29 @@ resource "google_privateca_certificate_authority" "{{$.PrimaryResourceId}}" {
88
config {
99
subject_config {
1010
subject {
11-
organization = "HashiCorp"
11+
organization = "ACME"
1212
common_name = "my-certificate-authority"
1313
}
14-
subject_alt_name {
15-
dns_names = ["hashicorp.com"]
16-
}
1714
}
1815
subject_key_id {
1916
key_id = "4cf3372289b1d411b999dbb9ebcd44744b6b2fca"
2017
}
2118
x509_config {
2219
ca_options {
2320
is_ca = true
24-
max_issuer_path_length = 10
2521
}
2622
key_usage {
2723
base_key_usage {
28-
digital_signature = true
29-
content_commitment = true
30-
key_encipherment = false
31-
data_encipherment = true
32-
key_agreement = true
3324
cert_sign = true
3425
crl_sign = true
35-
decipher_only = true
3626
}
3727
extended_key_usage {
38-
server_auth = true
39-
client_auth = false
40-
email_protection = true
41-
code_signing = true
42-
time_stamping = true
4328
}
4429
}
4530
}
4631
}
47-
lifetime = "86400s"
32+
# valid for 10 years
33+
lifetime = "${10 * 365 * 24 * 3600}s"
4834
key_spec {
4935
cloud_kms_key_version = "{{index $.Vars "kms_key_name"}}/cryptoKeyVersions/1"
5036
}

mmv1/templates/terraform/examples/privateca_certificate_authority_subordinate.tf.tmpl

+10-24
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,9 @@ resource "google_privateca_certificate_authority" "root-ca" {
55
config {
66
subject_config {
77
subject {
8-
organization = "HashiCorp"
8+
organization = "ACME"
99
common_name = "my-certificate-authority"
1010
}
11-
subject_alt_name {
12-
dns_names = ["hashicorp.com"]
13-
}
1411
}
1512
x509_config {
1613
ca_options {
@@ -24,7 +21,6 @@ resource "google_privateca_certificate_authority" "root-ca" {
2421
crl_sign = true
2522
}
2623
extended_key_usage {
27-
server_auth = false
2824
}
2925
}
3026
}
@@ -52,43 +48,33 @@ resource "google_privateca_certificate_authority" "{{$.PrimaryResourceId}}" {
5248
config {
5349
subject_config {
5450
subject {
55-
organization = "HashiCorp"
51+
organization = "ACME"
5652
common_name = "my-subordinate-authority"
5753
}
58-
subject_alt_name {
59-
dns_names = ["hashicorp.com"]
60-
}
6154
}
6255
x509_config {
6356
ca_options {
6457
is_ca = true
65-
# Force the sub CA to only issue leaf certs
66-
max_issuer_path_length = 0
58+
# Force the sub CA to only issue leaf certs.
59+
# Use e.g.
60+
# max_issuer_path_length = 1
61+
# if you need to chain more subordinates.
62+
zero_max_issuer_path_length = true
6763
}
6864
key_usage {
6965
base_key_usage {
70-
digital_signature = true
71-
content_commitment = true
72-
key_encipherment = false
73-
data_encipherment = true
74-
key_agreement = true
7566
cert_sign = true
7667
crl_sign = true
77-
decipher_only = true
7868
}
7969
extended_key_usage {
80-
server_auth = true
81-
client_auth = false
82-
email_protection = true
83-
code_signing = true
84-
time_stamping = true
8570
}
8671
}
8772
}
8873
}
89-
lifetime = "86400s"
74+
# valid for 5 years
75+
lifetime = "${5 * 365 * 24 * 3600}s"
9076
key_spec {
91-
algorithm = "RSA_PKCS1_4096_SHA256"
77+
algorithm = "RSA_PKCS1_2048_SHA256"
9278
}
9379
type = "SUBORDINATE"
9480
}

0 commit comments

Comments
 (0)