Skip to content

Conversation

@rfc2822
Copy link
Member

@rfc2822 rfc2822 commented Jan 25, 2026

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

  • 400 without client certificate and with
  • 404 with client certificate

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

  • The PR has a proper title, description and label.
  • I have self-reviewed the PR.
  • I have added documentation to complex functions and functions that can be used by other modules.
  • I have added reasonable tests or consciously decided to not add tests.

- 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
@rfc2822 rfc2822 changed the title [WIP] Reuse HTTPS connections Cache SSLSocketFactories to allow okhttp HTTPS connection reuse Jan 27, 2026
@rfc2822 rfc2822 marked this pull request as ready for review January 27, 2026 19:57
@rfc2822 rfc2822 requested a review from a team as a code owner January 27, 2026 19:57
@rfc2822 rfc2822 self-assigned this Jan 27, 2026
@rfc2822 rfc2822 added the bug Something isn't working label Jan 27, 2026
@rfc2822 rfc2822 linked an issue Jan 27, 2026 that may be closed by this pull request
@rfc2822 rfc2822 requested a review from sunkup January 28, 2026 11:24
@rfc2822 rfc2822 requested a review from sunkup January 29, 2026 12:43
Copy link
Member

@sunkup sunkup left a 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.

@rfc2822 rfc2822 requested a review from sunkup January 29, 2026 13:08
@rfc2822 rfc2822 merged commit ef1d90f into main-ose Jan 29, 2026
6 checks passed
@rfc2822 rfc2822 deleted the reuse-https-connections branch January 29, 2026 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTTPS connections not reused in many times

3 participants