marinofaggiana 5 년 전
부모
커밋
d85137b47d

+ 1 - 0
File Provider Extension/FileProviderExtension-Bridging-Header.h

@@ -36,3 +36,4 @@
 #import "OCSharedDto.h"
 #import "HCFeatures.h"
 #import "NCComments.h"
+#import "CCCertificate.h"

+ 1 - 0
Share/Share-Bridging-Header.h

@@ -12,3 +12,4 @@
 #import "OCSharedDto.h"
 #import "HCFeatures.h"
 #import "NCComments.h"
+#import "CCCertificate.h"

+ 12 - 1
iOSClient/Networking/NCCommunication.swift

@@ -25,7 +25,7 @@ import Foundation
 import Alamofire
 import SwiftyXMLParser
 
-class NCCommunication: NSObject {
+class NCCommunication: SessionDelegate {
     @objc static let sharedInstance: NCCommunication = {
         let instance = NCCommunication()
         return instance
@@ -283,6 +283,17 @@ class NCCommunication: NSObject {
             }
         }
     }
+    
+    //MARK: - SessionDelegate
 
+    func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
+        
+        if CCCertificate.sharedManager().checkTrustedChallenge(challenge) {
+            completionHandler(URLSession.AuthChallengeDisposition.performDefaultHandling,             URLCredential.init(trust: challenge.protectionSpace.serverTrust!))
+        } else {
+            completionHandler(URLSession.AuthChallengeDisposition.performDefaultHandling, nil)
+        }
+        
+    }
 }
 

+ 1 - 0
iOSClient/Nextcloud-Bridging-Header.h

@@ -27,3 +27,4 @@
 #import "NCRichDocumentTemplate.h"
 #import "HCFeatures.h"
 #import "NCComments.h"
+#import "CCCertificate.h"

+ 1 - 1
iOSClient/Security/CCCertificate.h

@@ -35,7 +35,7 @@
 
 @property (weak) id<CCCertificateDelegate> delegate;
 
-+ (id)sharedManager;
++ (CCCertificate *)sharedManager;
 
 - (BOOL)checkTrustedChallenge:(NSURLAuthenticationChallenge *)challenge;
 - (BOOL)acceptCertificate;

+ 1 - 1
iOSClient/Security/CCCertificate.m

@@ -30,7 +30,7 @@
 @implementation CCCertificate
 
 //Singleton
-+ (id)sharedManager {
++ (CCCertificate *)sharedManager {
     static CCCertificate *CCCertificate = nil;
     static dispatch_once_t onceToken;
     dispatch_once(&onceToken, ^{