Skip to content

Commit 8f46bc3

Browse files
privateca: update certificate authority samples with more realistic values (#12259) (#848)
[upstream:27812e087aaf4250c076b5d572b3934c1a013e2e] Signed-off-by: Modular Magician <[email protected]>
1 parent 753b767 commit 8f46bc3

File tree

2 files changed

+15
-41
lines changed
  • privateca_certificate_authority_basic
  • privateca_certificate_authority_subordinate

2 files changed

+15
-41
lines changed

privateca_certificate_authority_basic/main.tf

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,40 +8,28 @@ resource "google_privateca_certificate_authority" "default" {
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
}

privateca_certificate_authority_subordinate/main.tf

Lines changed: 10 additions & 24 deletions
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" "default" {
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)