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

Fix HostCAs not being returned during bot renewal #44832

Merged
merged 1 commit into from
Jul 31, 2024
Merged
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
7 changes: 6 additions & 1 deletion lib/auth/auth_with_roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -3385,8 +3385,13 @@ func (a *ServerWithRoles) generateUserCerts(ctx context.Context, req proto.UserC
// If the cert is renewable, process any certificate generation counter.
if certReq.renewable {
currentIdentityGeneration := a.context.Identity.GetIdentity().Generation

if experiment.Enabled() {
// If we're handling a renewal for a bot, we want to return the
// Host CAs as well as the User CAs.
if certReq.botName != "" {
certReq.includeHostCA = true
}

// Update the bot instance based on this authentication. This may create
// a new bot instance record if the identity is missing an instance ID.
if err := a.authServer.updateBotInstance(
Expand Down
3 changes: 3 additions & 0 deletions lib/auth/bot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ func TestRegisterBotCertificateGenerationCheck(t *testing.T) {
renewedIdent, err := tlsca.FromSubject(renewedCert.Subject, renewedCert.NotAfter)
require.NoError(t, err)

// Validate that we receive 2 TLS CAs (Host and User)
require.Len(t, certs.TLSCACerts, 2)

// Cert must be renewable.
require.True(t, renewedIdent.Renewable)
require.False(t, renewedIdent.DisallowReissue)
Expand Down
Loading