-
-
Notifications
You must be signed in to change notification settings - Fork 112
Cache SSLSocketFactories to allow okhttp HTTPS connection reuse #1942
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
Merged
+423
−74
Conversation
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
- Update bitfire-cert4android to 75cc6913fd - Refactor HttpClientBuilder to use Optional for customTrustManager and customHostnameVerifier - Add CustomCertManagerModule for dependency injection
- Introduce `ConnectionSecurityManager` and `ConnectionSecurityContext` classes - Refactor `HttpClientBuilder` to use the new security manager for SSL context setup
- Add context cache using Guava CacheBuilder - Cache SSLContext in getContext method
- Change socketFactoryCache to use LinkedHashMap instead of ConcurrentHashMap - Update cache key handling to use String? instead of Optional<String>
sunkup
requested changes
Jan 29, 2026
app/src/main/kotlin/at/bitfire/davdroid/di/CustomCertManagerModule.kt
Outdated
Show resolved
Hide resolved
app/src/main/kotlin/at/bitfire/davdroid/network/ConnectionSecurityManager.kt
Outdated
Show resolved
Hide resolved
app/src/main/kotlin/at/bitfire/davdroid/network/ConnectionSecurityManager.kt
Show resolved
Hide resolved
sunkup
requested changes
Jan 29, 2026
Member
sunkup
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests fail. See comment.
app/src/test/kotlin/at/bitfire/davdroid/network/ConnectionSecurityManagerTest.kt
Show resolved
Hide resolved
sunkup
approved these changes
Jan 29, 2026
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.
Purpose
Allow HTTPS connection reuse by reusing the SSLSocketFactories/TrustManagers.
Short description
SSLSocketFactory and TrustManager is now cached per client certificate alias.
So for every connection with the same (or no) certificate alias, the same SSLSocketFactory and TrustManager is used. This is a requirement for okhttp to use the connection pool (= reuse connections).
Hints for testing
You can use https://badssl.com/ (see Client Certificate) to verify that client certificates are still at least working by checking that the server responds with
when logging in over Advanced login.
However it would be very useful to have a working test server with client certificates again. (We had a Radicale with various configurations previously.) See https://github.com/bitfireAT/admin/issues/50
Checklist