From a7bdd24bdd72cbbb58037076d9750267ff96746b Mon Sep 17 00:00:00 2001 From: Alexander Scheel Date: Tue, 25 Apr 2023 09:59:25 -0400 Subject: [PATCH 1/3] Fix patching issuer leaf_not_after_behavior Signed-off-by: Alexander Scheel --- builtin/logical/pki/path_fetch_issuers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/logical/pki/path_fetch_issuers.go b/builtin/logical/pki/path_fetch_issuers.go index 003286a52f7d..e86f36378d90 100644 --- a/builtin/logical/pki/path_fetch_issuers.go +++ b/builtin/logical/pki/path_fetch_issuers.go @@ -783,7 +783,7 @@ func (b *backend) pathPatchIssuer(ctx context.Context, req *logical.Request, dat } // Leaf Not After Changes - rawLeafBehaviorData, ok := data.GetOk("leaf_not_after_behaivor") + rawLeafBehaviorData, ok := data.GetOk("leaf_not_after_behavior") if ok { rawLeafBehavior := rawLeafBehaviorData.(string) var newLeafBehavior certutil.NotAfterBehavior From ee1dc4e6a6905fcd3bb874523240029679600e53 Mon Sep 17 00:00:00 2001 From: Alexander Scheel Date: Tue, 25 Apr 2023 10:00:44 -0400 Subject: [PATCH 2/3] Add tests for patching leaf_not_after_behavior Signed-off-by: Alexander Scheel --- builtin/logical/pki/backend_test.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/builtin/logical/pki/backend_test.go b/builtin/logical/pki/backend_test.go index 4b0cdf7f4a92..ada179d4166f 100644 --- a/builtin/logical/pki/backend_test.go +++ b/builtin/logical/pki/backend_test.go @@ -4984,12 +4984,13 @@ func TestIssuanceTTLs(t *testing.T) { }) require.Error(t, err, "expected issuance to fail due to longer default ttl than cert ttl") - resp, err = CBWrite(b, s, "issuer/root", map[string]interface{}{ - "issuer_name": "root", + resp, err = CBPatch(b, s, "issuer/root", map[string]interface{}{ "leaf_not_after_behavior": "permit", }) require.NoError(t, err) require.NotNil(t, resp) + require.NotNil(t, resp.Data) + require.Equal(t, resp.Data["leaf_not_after_behavior"], "permit") _, err = CBWrite(b, s, "issue/local-testing", map[string]interface{}{ "common_name": "testing", @@ -5002,6 +5003,8 @@ func TestIssuanceTTLs(t *testing.T) { }) require.NoError(t, err) require.NotNil(t, resp) + require.NotNil(t, resp.Data) + require.Equal(t, resp.Data["leaf_not_after_behavior"], "truncate") _, err = CBWrite(b, s, "issue/local-testing", map[string]interface{}{ "common_name": "testing", From 12ef5d4a51524f9d4216a4ec215014d5983ed4d0 Mon Sep 17 00:00:00 2001 From: Alexander Scheel Date: Tue, 25 Apr 2023 10:28:07 -0400 Subject: [PATCH 3/3] Add changelog entry Signed-off-by: Alexander Scheel --- changelog/20341.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changelog/20341.txt diff --git a/changelog/20341.txt b/changelog/20341.txt new file mode 100644 index 000000000000..652e5735ea7b --- /dev/null +++ b/changelog/20341.txt @@ -0,0 +1,3 @@ +```release-note:bug +secrets/pki: Fix patching of leaf_not_after_behavior on issuers. +```