Skip to content

Fix authentication challenge completion handler not being called#35

Open
Eli-Liebman wants to merge 1 commit intodivar-ir:masterfrom
Eli-Liebman:fix/authentication-challenge-completion-handler
Open

Fix authentication challenge completion handler not being called#35
Eli-Liebman wants to merge 1 commit intodivar-ir:masterfrom
Eli-Liebman:fix/authentication-challenge-completion-handler

Conversation

@Eli-Liebman
Copy link

Hey! I ran into an issue where requests using client certificate authentication were hanging indefinitely when NetShears was enabled.

After digging in, I found that the urlSession(_:didReceive:completionHandler:) method only calls the completionHandler when the authentication method is NSURLAuthenticationMethodServerTrust and serverTrust is non-nil. For any other authentication type (like NSURLAuthenticationMethodClientCertificate), the completion handler never gets called and the connection hangs/timeouts.

This PR adds a fallback at the end of the method that calls completionHandler(.performDefaultHandling, nil) for any cases that aren't explicitly handled, which lets the system handle them normally.

The urlSession(_:didReceive:completionHandler:) method was only calling
the completionHandler for NSURLAuthenticationMethodServerTrust challenges
when serverTrust was non-nil. This caused other authentication methods
(e.g., NSURLAuthenticationMethodClientCertificate) to hang indefinitely
as the completionHandler was never invoked.

Added fallback to ensure completionHandler is always called with
.performDefaultHandling for unhandled cases.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant