Skip to content

Commit 735016d

Browse files
authored
Fix bug when writing auto tidy config field tidy_cmpv2_nonce_store (#29852)
* Fix bug when writing auto tidy config field tidy_cmpv2_nonce_store.
1 parent a213c04 commit 735016d

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

builtin/logical/pki/path_tidy.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func (tc *tidyConfig) IsAnyTidyEnabled() bool {
116116
}
117117

118118
func (tc *tidyConfig) AnyTidyConfig() string {
119-
return "tidy_cert_store / tidy_revoked_certs / tidy_revoked_cert_issuer_associations / tidy_expired_issuers / tidy_move_legacy_ca_bundle / tidy_revocation_queue / tidy_cross_cluster_revoked_certs / tidy_acme"
119+
return "tidy_cert_store / tidy_revoked_certs / tidy_revoked_cert_issuer_associations / tidy_expired_issuers / tidy_move_legacy_ca_bundle / tidy_acme / tidy_cross_cluster_revoked_certs / tidy_revocation_queue / tidy_cert_metadata / tidy_cmpv2_nonce_store"
120120
}
121121

122122
func (tc *tidyConfig) CalculateStartupBackoff(mountStartup time.Time) time.Time {
@@ -1779,6 +1779,13 @@ func (b *backend) pathConfigAutoTidyWrite(ctx context.Context, req *logical.Requ
17791779
}
17801780
}
17811781

1782+
if tidyCmpv2NonceStoreRaw, ok := d.GetOk("tidy_cmpv2_nonce_store"); ok {
1783+
config.CMPV2NonceStore = tidyCmpv2NonceStoreRaw.(bool)
1784+
if config.CMPV2NonceStore && !constants.IsEnterprise {
1785+
return logical.ErrorResponse("CMPv2 is only supported on Vault Enterprise"), nil
1786+
}
1787+
}
1788+
17821789
if config.Enabled && !config.IsAnyTidyEnabled() {
17831790
return logical.ErrorResponse("Auto-tidy enabled but no tidy operations were requested. Enable at least one tidy operation to be run (" + config.AnyTidyConfig() + ")."), nil
17841791
}
@@ -1829,6 +1836,7 @@ func (b *backend) tidyStatusStart(config *tidyConfig) {
18291836
tidyCrossRevokedCerts: config.CrossRevokedCerts,
18301837
tidyAcme: config.TidyAcme,
18311838
tidyCertMetadata: config.CertMetadata,
1839+
tidyCMPV2NonceStore: config.CMPV2NonceStore,
18321840
pauseDuration: config.PauseDuration.String(),
18331841

18341842
state: tidyStatusStarted,

builtin/logical/pki/path_tidy_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,13 @@ func TestTidyConfigs(t *testing.T) {
3939
require.Greater(t, len(operations), 1, "expected more than one operation")
4040
t.Logf("Got tidy operations: %v", operations)
4141

42-
lastOp := operations[len(operations)-1]
42+
lastOp := "tidy_acme"
4343

4444
for _, operation := range operations {
45+
if operation == "tidy_cmpv2_nonce_store" || operation == "tidy_cert_metadata" {
46+
// Skip, since these require ENT
47+
continue
48+
}
4549
b, s := CreateBackendWithStorage(t)
4650

4751
resp, err := CBWrite(b, s, "config/auto-tidy", map[string]interface{}{

changelog/29852.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
secrets/pki: Fix a bug that prevents enabling automatic tidying of the CMPv2 nonce store.
3+
```

0 commit comments

Comments
 (0)