Skip to content

Commit

Permalink
Fix missing SSH HostCA in tbot impersonated identities (#12932)
Browse files Browse the repository at this point in the history
This fixes a bug where the SSH HostCA is missing in impersonated
identities. We only include it in primary identities via the
server-side `includeHostCA` flag which can't be directly set by
clients. Without this CA, impersonated identities can't successfully
connect to the auth server via an SSH tunnel, so database requests
fail when using IoT joining.

We fix this by instead copying SSH CAs from the primary identity.
  • Loading branch information
timothyb89 authored May 27, 2022
1 parent 8f36b9c commit e8cfe5d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tool/tbot/renew.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,13 @@ func generateIdentity(
certs.TLSCACerts = append(certs.TLSCACerts, pemBytes)
}

// Do not trust SSH CA certs as returned by GenerateUserCerts() with an
// impersonated identity. It only returns the SSH UserCA in this context,
// but we also need the HostCA and can't directly set `includeHostCA` as
// part of the UserCertsRequest.
// Instead, copy the SSHCACerts from the primary identity.
certs.SSHCACerts = currentIdentity.SSHCACertBytes

newIdentity, err := identity.ReadIdentityFromStore(&identity.LoadIdentityParams{
PrivateKeyBytes: privateKey,
PublicKeyBytes: publicKey,
Expand Down Expand Up @@ -371,8 +378,6 @@ func renewIdentityViaAuth(
currentIdentity *identity.Identity,
cfg *config.BotConfig,
) (*identity.Identity, error) {
// TODO: enforce expiration > renewal period (by what mwargin?)

// If using the IAM join method we always go through the initial join flow
// and fetch new nonrenewable certs
var joinMethod types.JoinMethod
Expand Down

0 comments on commit e8cfe5d

Please sign in to comment.