[Bug]: T3 Connect: The environment credential is invalid. #5332
Before submitting#
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area#
apps/desktop
Steps to reproduce#
Trying to connect to another remote environment
Expected behavior#
T3 would connect and have access to such environment
Actual behavior#
I have 3 machines in my network, all of them connect to T3 Connect and all of them can connect to each other, except my Macbook can't connect to the Windows instance. The error is: The environment credential is invalid.
Impact#
Blocks work completely
Version or commit#
0.0.32
Environment#
27.0 Beta (26A5388g), Windows 11
Logs or stack traces#
Trace ID: 397a5a9c7c80045bcc7f3cd117837401
Screenshots, recordings, or supporting files#
Workaround#
No response
paulomanrique(GitHub profile, opens in a new tab) added labelsbug
paulomanrique(GitHub profile, opens in a new tab) added labelsneeds-triage
Update: I resolved my reproduction. This was not caused by a corrupt persisted environment credential.
After adding credential-safe diagnostics around DPoP verification, the server reported the actual rejection reason:
DPoP proof verification failed reason: DPoP proof is outside the allowed time window. requestProtocol: https: requestHost: prod-aa75a8b4828aa058.t3coderelay.com requestPath: /oauth/token forwardedProtocol: https cloudflareVisitor: {"scheme":"https"}The VPS clock was not synchronized:
System clock synchronized: no NTP service: active Packet count: 0NTP requests were timing out because UDP response traffic was blocked by the provider firewall. Once I allowed incoming UDP traffic from source port 123 and restarted
systemd-timesyncd, it synchronized and corrected approximately 11 seconds of clock drift:System clock synchronized: yes Offset: +10.959798s Packet count: 1The existing T3 Connect environment then connected successfully from the mobile app without relinking or regenerating its credential.
There was a separate network issue where Cloudflare Tunnel could not establish QUIC because UDP was blocked. Running the tunnel over HTTP/2 with
TUNNEL_TRANSPORT_PROTOCOL=http2handled that; it was not the cause of theinvalid_credentialresponse.So, for my reproduction:
- The environment credential was valid.
- The public HTTPS request URL was reconstructed correctly.
- The
401 invalid_credentialresponse was caused by clock skew during DPoP verification. - Restoring working NTP synchronization fixed the connection.
Other reports on this issue may still have different causes, but regenerating the environment credential was not required in my case.
I just ran into the same issue. In my case, the Windows environment host’s clock was about 11 seconds behind.
After diagnosing it with T3 (ha!), clicking Sync now under Windows Settings → Time & language → Date & time fixed the connection immediately. I did not need to relink the environment or regenerate its credentials.
This matches the clock-skew diagnosis above. I’d suggest that when authentication fails specifically because the DPoP proof falls outside the permitted time window, the app show a more actionable message:
The environment host’s clock appears out of sync. Sync its date and time, then retry.
Other invalid-credential failures can remain generic.
One thing I noticed, is that if you try add the 4th device in the tunnel, you also get this error message instead of something reporting you ran out of devices, subscribe and whatever.
I get the same error on Android mobile trying to connect to my desktop. Over time more and more "T3 Connect connect" connections are made.
juliusmarminge closed this
Root cause for the clock-skew reproductions in this thread (from the closed #17186, preserved here as requested):
verifyDpopProofinpackages/shared/src/dpop.tsaccepts a proof whoseiatis up to 300 seconds in the past but only 5 seconds in the future. The environment server and the relay both use it. So when the verifying machine's clock runs more than 5 seconds behind the client's, every proof is rejected withtime_window, and the client shows "The environment credential is invalid."Reproduction:
- Set the environment host's clock about 10 seconds behind real time (for example, turn off automatic time on Windows and move it back).
- Connect to that environment from another device with a synced clock, over T3 Connect or
t3 serve. - Every request fails with "The environment credential is invalid." The server logs
DPoP proof is outside the allowed time window. - Sync the host clock (Windows: Settings > Time & language > Date & time > Sync now). The connection works again right away, with no relink.
Matching reports: the Windows host about 11 seconds behind and the VPS about 11 seconds off in this issue, #9676 (Android with automatic time off), and the VirtualBox guest drifting 13 to 43 seconds behind, reported on #17186.
A smaller fix that only makes the tolerance symmetric (300 seconds either way) and extends the relay replay marker to match is in #19640.
Sign in to join this conversation.
I am also facing the same error. For me I am not using t3 connect instead I am getting this error when using
t3 serve. The generated code works correctly for the first device. Any attempt to add the same remote environment on any other device results in this error.