Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions vault/resource_pki_secret_backend_root_sign_intermediate.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,15 @@ func pkiSecretBackendRootSignIntermediateResource() *schema.Resource {
ForceNew: true,
Default: -1,
},
consts.FieldKeyUsage: {
Type: schema.TypeList,
Optional: true,
Description: "Specify the key usages to be added to the existing set of key usages, CRL,CertSign, on the generated certificate.",
ForceNew: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
consts.FieldExcludeCNFromSans: {
Type: schema.TypeBool,
Optional: true,
Expand Down Expand Up @@ -361,6 +370,7 @@ func pkiSecretBackendRootSignIntermediateCreate(ctx context.Context, d *schema.R
consts.FieldURISans,
consts.FieldOtherSans,
consts.FieldPermittedDNSDomains,
consts.FieldKeyUsage,
}

// Whether name constraints fields (other than permitted_dns_domains), are supproted,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,25 @@ func TestPkiSecretBackendRootSignIntermediate_basic_default(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, consts.FieldUsePSS, "true"),
),
},
{
SkipFunc: skip(provider.VaultVersion118),
Config: testPkiSecretBackendRootSignIntermediateConfig_basic(rootPath, intermediatePath, false,
`key_usage = ["DigitalSignature", "CertSign"]`),
Check: resource.ComposeTestCheckFunc(
checks,
resource.TestCheckResourceAttr(resourceName, consts.FieldKeyUsage+".#", "2"),
resource.TestCheckResourceAttr(resourceName, consts.FieldKeyUsage+".0", "DigitialSignature"),
resource.TestCheckResourceAttr(resourceName, consts.FieldKeyUsage+".1", "CertSign"),
testPKICert(resourceName, func(cert *x509.Certificate) error {
if 0 == cert.KeyUsage&x509.KeyUsageKeyAgreement || 0 == cert.KeyUsage&x509.KeyUsageCertSign {
return fmt.Errorf("KeyUsage expected %b, got %b",
x509.KeyUsageDigitalSignature|x509.KeyUsageCertSign|x509.KeyUsageCRLSign,
cert.KeyUsage)
}
return nil
}),
),
},
},
})
}
Expand Down
Loading