-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Fix serverTrust crash #4542
Fix serverTrust crash #4542
Conversation
Thanks for the fix! Can you add a unit test that triggers the crash (without your fix) in order to avoid a future potential regression? |
@Kaspik May I ask why did you close this pull request? |
Hah, I merged my other PR and it closed this one. I'll reopen. |
Are you comfortable to add a unit test that triggers the crash (without your fix) in order to avoid a future potential regression or would you prefer me to add the unit test? |
I'm already out from my computer for the weekend, so feel free to do it otherwise I'll try on Monday. :) |
ping @Kaspik |
As Let me know if you have any other idea how to revert this but still test it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the work, I like the solution, but I don't really want to make the helper function public just to test it. Perhaps you can test using the delegate method instead so we only test public API?
@@ -447,6 +447,8 @@ NS_ASSUME_NONNULL_BEGIN | |||
*/ | |||
- (void)setDownloadTaskDidResumeBlock:(nullable void (^)(NSURLSession *session, NSURLSessionDownloadTask *downloadTask, int64_t fileOffset, int64_t expectedTotalBytes))block; | |||
|
|||
+ (nonnull NSError *)serverTrustErrorWithServerTrust:(nonnull SecTrustRef)serverTrust url:(nonnull NSURL *)url; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather not make this method public. Instead of testing the error method directly, perhaps you can test the delegate method which creates the error? I do like the nullability annotations though, so applying those to the function might be helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how to "repro" the case where it returns with no server trust - so if anyone has, feel free to give me a hint or final solution.
Merging to branch to add tests but will credit this PR with the change. |
* Fix serverTrust crash (#4542) * Update readme, add stale bot, add issue template, add pull request template * Update copy from Alamofire * Fix crash on nil serverTrust * Expose server trust error * add test for error throws * Fix nullability * Fix evaluateServerTrust determination (#4552) Co-authored-by: Jon Shier <jon@jonshier.com> * Revert changes making error generation public. This reverts commit 111352b. # Conflicts: # AFNetworking/AFURLSessionManager.m * Make static error function a method instead. * Make trust generatio part of AFTestCase. * Add test cases for server trust error generation. * Mark parameters explicitly nullable. * Fix nullability (#4551) * Replace instead of appending to the default header (#4550) * Replace instead of appending to the default header * Add tests for setting HTTP headers per request * Fix SPM usage with better publicHeadersPath. (#4554) Co-authored-by: Jakub Kašpar <kaspikk@gmail.com> Co-authored-by: Elf Sundae <elf.sundae@gmail.com>
Issue Link 🔗
Goals ⚽
Implementation Details 🚧
challenge.protectionSpace.serverTrust
is nil if the authentication method of the protection space is not server trust