Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ca: set the correct SigningKeyID after config update with Vault provider #11672

Merged
merged 1 commit into from
Dec 2, 2021

Conversation

dnephin
Copy link
Contributor

@dnephin dnephin commented Nov 26, 2021

Fixes #11662
Branched from #11671

Two other instance of this same bug were fixed a year+ ago in #6513 and #7012, but this last one remained.

The test failed before the fix, and I extracted a new function for this since the logic is the same in all places, and the method name helps indicate the significance of this intermediate certificate.

We already have logic to fix the SigningKeyID on stored CARoot when the CAMananger is initialized, so we don't need to add more logic for it.

@dnephin dnephin added theme/certificates Related to creating, distributing, and rotating certificates in Consul type/bug Feature does not function as expected labels Nov 26, 2021
@dnephin dnephin requested a review from a team November 26, 2021 22:37

cert, err = connect.ParseCert(newRoot.LeafSigningCert())
require.NoError(t, err)
require.Equal(t, connect.HexString(cert.SubjectKeyId), newRoot.SigningKeyID)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the line that failed before this fix.

Copy link
Contributor

@acpana acpana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 📦 !

@dnephin dnephin force-pushed the dnephin/ca-fix-storing-vault-intermediate branch from d155347 to b631479 Compare December 1, 2021 00:26
@dnephin dnephin force-pushed the dnephin/ca-fix-signing-key-id-post-update branch from 398a805 to 0373c1b Compare December 1, 2021 19:42
@vercel vercel bot temporarily deployed to Preview – consul-ui-staging December 1, 2021 19:42 Inactive
@vercel vercel bot temporarily deployed to Preview – consul December 1, 2021 19:42 Inactive
@dnephin dnephin force-pushed the dnephin/ca-fix-signing-key-id-post-update branch from 0373c1b to bea9b46 Compare December 1, 2021 19:53
@vercel vercel bot temporarily deployed to Preview – consul-ui-staging December 1, 2021 19:53 Inactive
@vercel vercel bot temporarily deployed to Preview – consul December 1, 2021 19:53 Inactive
@dnephin dnephin force-pushed the dnephin/ca-fix-storing-vault-intermediate branch from b631479 to 28a8a64 Compare December 2, 2021 17:42
Base automatically changed from dnephin/ca-fix-storing-vault-intermediate to main December 2, 2021 21:02
@dnephin dnephin force-pushed the dnephin/ca-fix-signing-key-id-post-update branch from bea9b46 to df8618d Compare December 2, 2021 21:04
@vercel vercel bot temporarily deployed to Preview – consul December 2, 2021 21:04 Inactive
@vercel vercel bot temporarily deployed to Preview – consul-ui-staging December 2, 2021 21:04 Inactive
The test added in this commit shows the problem. Previously the
SigningKeyID was set to the RootCert not the local leaf signing cert.

This same bug was fixed in two other places back in 2019, but this last one was
missed.

While fixing this bug I noticed I had the same few lines of code in 3
places, so I extracted a new function for them.

There would be 4 places, but currently the InitializeCA flow sets this
SigningKeyID in a different way, so I've left that alone for now.
@dnephin dnephin force-pushed the dnephin/ca-fix-signing-key-id-post-update branch from df8618d to 17a2d14 Compare December 2, 2021 21:07
@vercel vercel bot temporarily deployed to Preview – consul December 2, 2021 21:07 Inactive
@vercel vercel bot temporarily deployed to Preview – consul-ui-staging December 2, 2021 21:07 Inactive
@dnephin dnephin merged commit 0c7a225 into main Dec 2, 2021
@dnephin dnephin deleted the dnephin/ca-fix-signing-key-id-post-update branch December 2, 2021 21:24
@hc-github-team-consul-core
Copy link
Contributor

🍒 If backport labels were added before merging, cherry-picking will start automatically.

To retroactively trigger a backport after merging, add backport labels and re-run https://circleci.com/gh/hashicorp/consul/514121.

@hc-github-team-consul-core
Copy link
Contributor

🍒❌ Cherry pick of commit 0c7a225 onto release/1.10.x failed! Build Log

@hc-github-team-consul-core
Copy link
Contributor

🍒❌ Cherry pick of commit 0c7a225 onto release/1.9.x failed! Build Log

dnephin added a commit that referenced this pull request Dec 2, 2021
…d-post-update

ca: set the correct SigningKeyID after config update with Vault provider
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme/certificates Related to creating, distributing, and rotating certificates in Consul type/bug Feature does not function as expected
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ca: CARoot.SigningKeyID is wrong after config update when using the Vault CA provider
3 participants