Skip to content

Commit

Permalink
Issue certficate for desktop connection before actual connection (#30882
Browse files Browse the repository at this point in the history
)

Before this we initiated connection first, then tried to issue certificate,
which could require MFA check and that would lead to timeout in multiplexer,
since there was no data on the connection while user was doing MFA check.
  • Loading branch information
AntonAM committed Aug 23, 2023
1 parent 9039526 commit 1c5d0a7
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions lib/web/desktop.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,18 @@ func (h *Handler) createDesktopConnection(
validServiceIDs[i], validServiceIDs[j] = validServiceIDs[j], validServiceIDs[i]
})

pc, err := proxyClient(r.Context(), sctx, h.ProxyHostPort(), username, h.cfg.PROXYSigner)
if err != nil {
return sendTDPError(trace.Wrap(err))
}
defer pc.Close()

// Issue certificate for TLS config and pass MFA check if required.
tlsConfig, err := desktopTLSConfig(r.Context(), ws, pc, sctx, desktopName, username, site.GetName())
if err != nil {
return sendTDPError(err)
}

clientSrcAddr, clientDstAddr := utils.ClientAddrFromContext(r.Context())

c := &connector{
Expand All @@ -183,16 +195,6 @@ func (h *Handler) createDesktopConnection(
}
defer serviceConn.Close()

pc, err := proxyClient(r.Context(), sctx, h.ProxyHostPort(), username, h.cfg.PROXYSigner)
if err != nil {
return sendTDPError(trace.Wrap(err))
}
defer pc.Close()

tlsConfig, err := desktopTLSConfig(r.Context(), ws, pc, sctx, desktopName, username, site.GetName())
if err != nil {
return sendTDPError(err)
}
serviceConnTLS := tls.Client(serviceConn, tlsConfig)

if err := serviceConnTLS.HandshakeContext(r.Context()); err != nil {
Expand Down

0 comments on commit 1c5d0a7

Please sign in to comment.