fix: add explicit default auth challenge handling to SessionDelegate#51
Merged
Recouse merged 1 commit intoMay 14, 2026
Merged
Conversation
Without implementing urlSession(_:didReceive challenge:), URLSession may silently reject server certificates in certain proxy/MITM scenarios (e.g., mitmproxy, Charles Proxy) even when the CA certificate is installed and trusted at the OS level. Adding explicit .performDefaultHandling ensures the system's default trust evaluation is used, which correctly respects user-installed CA certificates. This has no effect on normal (non-proxy) connections.
f962b84 to
47b2713
Compare
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.
Summary
urlSession(_:didReceive challenge:completionHandler:)toSessionDelegatewith.performDefaultHandlingCloses #50
Problem
When using EventSource through an MITM proxy with a trusted CA certificate installed at the OS level, SSE connections fail silently. The request never reaches the proxy and no error events are emitted.
SessionDelegateimplementsURLSessionDataDelegatebut does not implement the authentication challenge delegate method. WhileURLSessionshould fall back to default system trust evaluation, in practice this can cause connections to be silently rejected when a custom delegate is present without explicit challenge handling.Fix
Add explicit
.performDefaultHandlingtoSessionDelegate:This explicitly delegates to the system's default trust evaluation, which correctly respects user-installed CA certificates. This has no effect on normal (non-proxy) connections — it simply makes the default behavior explicit rather than implicit.