You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Android: pinned OkHttpClient lazy fallback can permanently bind to non-pinned client #7248
MediaCallsAnswerRequest.kt:45-53 and DDPClient.kt:29 both initialize the OkHttp client via a companion by lazy block:
```kotlin
private val httpClient: OkHttpClient by lazy {
SSLPinningTurboModule.getSharedOkHttpClient() ?: OkHttpClient()
}
```
If a VoIP notification (or DDP message) arrives during cold start before the user has selected a certificate, the lazy initializer triggers when the shared pinned client is still null, permanently binding to a plain OkHttpClient() for the process lifetime. Subsequent calls — including manual certificate selection later in the session — reuse the cached non-pinned fallback and silently bypass SSL pinning.
Where this surfaces
VoIP accept REST (MediaCallsAnswerRequest.fetch) when invoked from a PushKit/FCM cold-start handler
DDPClient connections under similar cold-start conditions
Suggested fix
Resolve the shared client at each call site rather than at lazy initialization, OR fail-fast with onResult(false) when getSharedOkHttpClient() returns null.
Background
Spotted by CodeRabbit on #7245 — this is a pre-existing bug, not introduced by that PR. Filing separately so it doesn't block the release-readiness queue.
I looked at both MediaCallsAnswerRequest.kt and DDPClient.kt in feat.voip-lib-new.
The root cause is that the by lazy initializer runs once at first use. If a VoIP notification arrives before SSLPinningTurboModule has a shared client ready, the fallback plain OkHttpClient() gets cached permanently for the process lifetime.
Two approaches:
Option A — resolve at call site: Drop the by lazy and call SSLPinningTurboModule.getSharedOkHttpClient() inside execute() / connect() each time. Build the client with the required timeouts on every call. No permanent caching.
Option B — fail-fast: Keep the lazy pattern but replace ?: OkHttpClient() with an explicit null check — if the shared client is not ready, immediately invoke onResult(false) / the connect callback with false and return. No silent downgrade to an unpinned client.
Option B is simpler and arguably safer since it makes the failure explicit rather than silently proceeding without pinning. Option A works too but rebuilds the client on every call.
What are your views on it? Happy to submit a PR for whichever approach you prefer.
Fixed by fix: send client certificate through expo/fetch on iOS and Android (4.78.0): the shared OkHttp client factory with client-certificate support is installed when the app process starts, before any VoIP push or DDP connection, and the fallback to a plain OkHttpClient is gone. Certificates picked later apply to existing clients too. Closing.
Activity
deepak0x commentedon Apr 28, 2026
I looked at both
MediaCallsAnswerRequest.ktandDDPClient.ktinfeat.voip-lib-new.The root cause is that the
by lazyinitializer runs once at first use. If a VoIP notification arrives beforeSSLPinningTurboModulehas a shared client ready, the fallback plainOkHttpClient()gets cached permanently for the process lifetime.Two approaches:
Option A — resolve at call site: Drop the
by lazyand callSSLPinningTurboModule.getSharedOkHttpClient()insideexecute()/connect()each time. Build the client with the required timeouts on every call. No permanent caching.Option B — fail-fast: Keep the lazy pattern but replace
?: OkHttpClient()with an explicit null check — if the shared client is not ready, immediately invokeonResult(false)/ the connect callback withfalseand return. No silent downgrade to an unpinned client.Option B is simpler and arguably safer since it makes the failure explicit rather than silently proceeding without pinning. Option A works too but rebuilds the client on every call.
What are your views on it? Happy to submit a PR for whichever approach you prefer.
diegolmello commentedon Nov 26, 2026
Fixed by fix: send client certificate through expo/fetch on iOS and Android (4.78.0): the shared OkHttp client factory with client-certificate support is installed when the app process starts, before any VoIP push or DDP connection, and the fallback to a plain OkHttpClient is gone. Certificates picked later apply to existing clients too. Closing.