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

[v13] Fix connection to dekstop access service when session MFA is required #30963

Merged
merged 1 commit into from Aug 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 12 additions & 10 deletions lib/web/desktop.go
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