Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Reverted NSURLSessionAuthChallengeDisposition to NSURLSessionAuthChallengeCancelAuthenticationChallenge for SSL Pinning #3417

Merged
merged 2 commits into from Mar 31, 2016

Conversation

kcharwood
Copy link
Contributor

As first discussed in #3409, there appear to be cases where returning NSURLSessionAuthChallengeRejectProtectionSpace does not prevent the request from succeeding in some cases.

A few of us have starting to dig in on this issue. @0xced has seen behavior where the existing code does work in some cases, leading us to believe there may be some issues here related to the TLS cache under the hood that we do not control. However, using Cancel instead does give us deterministic control.

The original intent of moving to RejectProtectionSpace was to provide a better error message to the developer to distinguish between a manual cancel and an SSL pinning failure.

I've created a simple playground demonstrating the issue:

NSURLSessionAuthChallenge.playground.zip

This PR reverts to using cancel, and adds an additional test for Public Key Pinning error validation.

Note that if you have code specifically looking for NSURLErrorServerCertificateUntrusted, you should fall back to use NSURLErrorCancelled

…allengeCancelAuthenticationChallenge` to allow for more determistic pinning results.

- Updated test suite to check for new error code
@codecov-io
Copy link

Current coverage is 76.07%

Merging #3417 into master will decrease coverage by -0.40% as of 89570aa

@@            master   #3417   diff @@
======================================
  Files            5       5       
  Stmts         2491    2491       
  Branches         0       0       
  Methods                          
======================================
- Hit           1905    1895    -10
  Partial          0       0       
- Missed         586     596    +10

Review entire Coverage Diff as of 89570aa

Powered by Codecov. Updated on successful CI builds.

@cnoon
Copy link
Member

cnoon commented Mar 31, 2016

This all looks good to me @kcharwood. 👍🏼

Would it also be wise to put the Apple Forums link in this PR as well for reference?

@kcharwood
Copy link
Contributor Author

Thanks @cnoon

Here is a link to a Dev Forum I have opened:

https://forums.developer.apple.com/message/128153#128153

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants