Skip to content

fix: send the client certificate on connection check and token refresh - #267

Closed
welcometopwn wants to merge 2 commits into
opencloud-eu:mainfrom
welcometopwn:fix/mtls_token_refresh
Closed

welcometopwn wants to merge 2 commits into
opencloud-eu:mainfrom
welcometopwn:fix/mtls_token_refresh

Conversation

@welcometopwn

Copy link
Copy Markdown

Fixes #266

  • ConnectionValidator copies the client cert alias from the base client
  • refreshToken() puts the account's cert on the anonymous client for discovery and the token request, then restores it

Tested on a Galaxy S25+ against a server behind Cloudflare with mTLS enforced, mobile data only. After the token expired the refresh went through and files loaded, before it logged me out.

@guruz

guruz commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

CC @paolostivanin

@guruz
guruz requested a review from wernrab November 20, 2026 12:13
@paolostivanin

Copy link
Copy Markdown
Contributor

hello! thanks for the PR, and for testing it on a real device.

This is already covered by #237. It fixes the same two spots: the ConnectionValidator probe now sends the client cert, and so do OIDC discovery and the token request during refresh. It also fixes the other reasons you end up on the "token expired" screen: a failed refresh caused by a network error or timeout was reported as an expired session, the validator retried with stale credentials, two refreshes could run at the same time, etc.

One difference in approach: here refreshToken() swaps ClientManager.loginClientCertAlias and restores it afterwards. That's a shared singleton and there's no lock or finally. Two refreshes running at the same time, or a refresh while someone is adding a second account in the login screen, can leave the wrong alias in there. #237 passes the alias explicitly to the discovery and token requests instead (OIDCDiscoveryUseCase.Params, TokenRequest.RefreshToken), so nothing shared gets modified.

So I'd rather close this one as a duplicate and link #266 to #237. But since you have a Cloudflare mTLS setup and you're on mobile data only, could you give #237 a try? So far it has only been tested on my setup, so a second one would help a lot with getting it merged.

@welcometopwn

Copy link
Copy Markdown
Author

Duplicate of #237.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mTLS: "session expired" once the access token expires

3 participants