Skip to content

Commit

Permalink
Correctly set up transport service tls config
Browse files Browse the repository at this point in the history
Using `setupTLSConfigClientCAsForCluster` was overwriting the
tls.Config.ClientAuth on each client connection which caused falling
back to connecting via ssh.
  • Loading branch information
rosstimothy committed Apr 6, 2023
1 parent 8799006 commit 83a968e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -3857,12 +3857,25 @@ func (process *TeleportProcess) initProxyEndpoint(conn *Connector) error {
}

tlscfg := serverTLSConfig.Clone()
setupTLSConfigClientCAsForCluster(tlscfg, accessPoint, clusterName)
tlscfg.ClientAuth = tls.RequireAndVerifyClientCert
if lib.IsInsecureDevMode() {
tlscfg.InsecureSkipVerify = true
tlscfg.ClientAuth = tls.RequireAnyClientCert
}
tlscfg.GetConfigForClient = func(*tls.ClientHelloInfo) (*tls.Config, error) {
tlsClone := tlscfg.Clone()

// Build the client CA pool containing the cluster's user CA in
// order to be able to validate certificates provided by users.
var err error
tlsClone.ClientCAs, _, err = auth.DefaultClientCertPool(accessPoint, clusterName)
if err != nil {
return nil, trace.Wrap(err)
}

return tlsClone, nil
}

creds, err := auth.NewTransportCredentials(auth.TransportCredentialsConfig{
TransportCredentials: credentials.NewTLS(tlscfg),
UserGetter: authMiddleware,
Expand Down

0 comments on commit 83a968e

Please sign in to comment.