Repository navigation
Android: client certificate (mTLS) for the SSO token exchange #8629
zigatrcek
started this conversation in
Ideas & Feature Requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Before posting
Product area
Client / Agent, Mobile app, Identity provider / SSO, Self-hosting / Deployment
Problem or use case
As a self-hosted operator whose IdP requires mTLS, I want Android peers to sign in with SSO the same way desktop peers do.
#2188 added
ClientCertPath/ClientCertKeyPath: the desktop client presents a client certificate when it exchanges the PKCE authorization code at the IdP token endpoint. Android has no way to set this. The config fields are file paths in app-private storage, and the app has no UI for them.Sign-in on Android has two legs that reach the IdP:
oauth2: cannot parse json: invalid character '<'.So Android peers cannot join a deployment where the IdP requires client certificates.
Proposed solution
Let the Android app supply the certificate from the Android KeyChain, so one installed credential serves both legs.
KeyChain.choosePrivateKeyAlias). Picking it also grants the app access.crypto.Signerhands each TLS signature back to Java (NONEwithECDSA, orNONEwithRSAover a PKCS#1 DigestInfo).Where the setting lives in the app is open. Options, from simplest:
Alternatives or workarounds considered
ClientCertPathon Android. The config is not user-editable, and copying a private key into app storage defeats the hardware-backed KeyStore.Community impact and priority
Examples from other tools or products
Chrome on Android: on a TLS
CertificateRequestit shows the KeyChain picker naming the requesting host, remembers the choice, and signs through the KeyStore without exporting the key. The NetBird desktop client after #2188, which uses a cert/key file pair.Security, privacy, and compatibility considerations
ClientCertPathkeeps precedence.RSA/ECB/NoPadding).Implementation ideas
We have a working prototype, tested on a physical device and an Android 15 emulator against a self-hosted management server and an mTLS-enforcing IdP. The token exchange fails without the certificate and succeeds with it.
client/android, about 190 lines plus tests): a gomobileClientCertProviderinterface (CertificateChainPEM(),Sign(algorithm, data)). On interactive login and session extension, the provider's certificate is set asClientCertKeyPairon a copy of the config passed toauth.NewAuth. The shared engine config is not modified. Unit tests do real mTLS handshakes through the bridge signer.Questions for maintainers before we open PRs:
Auth/Clientlike the MDMPolicyFetcher, instead of being registered package-wide?pkce_flow.gouseGetClientCertificate, so the KeyStore is only consulted when the IdP actually requests a certificate?Are you willing to help?
Yes, I can submit a PR if the approach is accepted.
Additional context
Behaviour from the prototype:
oauth2: cannot parse json.invalid_grant, a real login succeeds).Screenshots:

Current behavior without certificate:
Prototype certificate picker:

Setting location and UI:

All reactions