Added support for client side certificates (mTLS)#125
Open
cat101 wants to merge 4 commits intojensomato:developfrom
Open
Added support for client side certificates (mTLS)#125cat101 wants to merge 4 commits intojensomato:developfrom
cat101 wants to merge 4 commits intojensomato:developfrom
Conversation
Author
|
I have pulled the latest changes from your repo and updated the PR. BTW: I have been using my build with mTLS support since October with no problems |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I use HAProxy to expose my self-hosted services to the Internet. In order prevent unauthorized access and discourage bots I use mutual authentication (mTLS). As of know the Readeck app would fail to connect to mTLS backend.
I have done this PR purelly using RooCode/Claude. I have 30 years of programming experience but I have never worked on Android. I have built the apk, sideloaded it to my device and verifyed that it works.
The rest is the PR description written by Claude and reviewed by me 😄
Summary
This PR adds support for mutual TLS (mTLS) client certificate authentication, enabling the app to connect to servers (like HAProxy) that require client certificates during the TLS handshake.
Problem
When connecting to servers configured with mTLS authentication, the app would fail with:
This occurred because the app wasn't providing a client certificate when the server requested one during the TLS handshake.
Solution
Implemented a complete mTLS solution that:
Changes
New Components
SSL/Certificate Management (
app/src/main/java/de/readeckapp/io/rest/ssl/):ClientCertificateManager.kt- Manages certificate selection and KeyChain integrationCustomX509KeyManager.kt- Provides certificates during TLS handshakeSSLConfigurationProvider.kt- Configures OkHttp with SSL supportCertificateSelectionHelper.kt- UI-friendly helper for certificate operationsModified Components
Network Layer:
NetworkModule.kt- Integrated SSL configuration with OkHttp clientSettingsDataStore.kt&SettingsDataStoreImpl.kt- Added certificate alias storageUI Layer:
AccountSettingsScreen.kt- Added certificate selection UI with "Select Client Certificate" buttonAccountSettingsViewModel.kt- Added certificate selection and management logicHow It Works