Marino Faggiana 8 years ago
parent
commit
b6c327cd5b
1 changed files with 7 additions and 6 deletions
  1. 7 6
      iOSClient/Networking/OCNetworking.m

+ 7 - 6
iOSClient/Networking/OCNetworking.m

@@ -1613,12 +1613,13 @@
 - (void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler
 {
     // The pinnning check
-    
-    if ([[CCCertificate sharedManager] checkTrustedChallenge:challenge]) {
-        completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]);
-    } else {
-        completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil);
-    }
+    dispatch_async(dispatch_get_main_queue(), ^{
+        if ([[CCCertificate sharedManager] checkTrustedChallenge:challenge]) {
+            completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]);
+        } else {
+            completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil);
+        }
+    });
 }
 
 @end