Skip to content
This repository was archived by the owner on Mar 16, 2019. It is now read-only.

Commit 06a466b

Browse files
committed
Fix IOS self-signed SSL issue #159
1 parent 008d754 commit 06a466b

File tree

1 file changed

+3
-21
lines changed

1 file changed

+3
-21
lines changed

src/ios/RNFetchBlobNetwork.m

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -598,32 +598,14 @@ + (void) cancelRequest:(NSString *)taskId
598598

599599
- (void) URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential * _Nullable credantial))completionHandler
600600
{
601-
if([options valueForKey:CONFIG_TRUSTY] != nil)
601+
BOOL trusty = [options valueForKey:CONFIG_TRUSTY];
602+
if(!trusty)
602603
{
603604
completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]);
604605
}
605606
else
606607
{
607-
NSURLSessionAuthChallengeDisposition disposition = NSURLSessionAuthChallengePerformDefaultHandling;
608-
__block NSURLCredential *credential = nil;
609-
if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust])
610-
{
611-
credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust];
612-
if (credential) {
613-
disposition = NSURLSessionAuthChallengeUseCredential;
614-
} else {
615-
disposition = NSURLSessionAuthChallengePerformDefaultHandling;
616-
}
617-
}
618-
else
619-
{
620-
disposition = NSURLSessionAuthChallengeCancelAuthenticationChallenge;
621-
RCTLogWarn(@"counld not create connection with an unstrusted SSL certification, if you're going to create connection anyway, add `trusty:true` to RNFetchBlob.config");
622-
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
623-
}
624-
if (completionHandler) {
625-
completionHandler(disposition, credential);
626-
}
608+
completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]);
627609
}
628610
}
629611

0 commit comments

Comments
 (0)