Forráskód Böngészése

修改raimage 和通用文件上传,去掉ssl 证书验证。

Ray Zhang 7 éve
szülő
commit
1ba450552f

BIN
RA Image/RA Image.xcodeproj/project.xcworkspace/xcuserdata/ray.xcuserdatad/UserInterfaceState.xcuserstate


+ 12 - 0
RA Image/RA Image/AppDelegate.m

@@ -215,3 +215,15 @@ void UncaughtExceptionHandler(NSException *exception) {
 
 
 @end
+@implementation NSURLRequest(DataController)
++ (BOOL)allowsAnyHTTPSCertificateForHost:(NSString *)host
+{
+    return YES;
+}
+@end
+//@implementation NSURLSession(DataController)
+//+ (BOOL)allowsAnyHTTPSCertificateForHost:(NSString *)host
+//{
+//    return YES;
+//}
+//@end

+ 1 - 0
common/NetworkUtils.m

@@ -57,6 +57,7 @@ repeat:
         NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]
                                                                cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
                                                            timeoutInterval:JSON_TIMEOUT];
+
         //分界线 --AaB03x
         NSString *MPboundary=[[NSString alloc]initWithFormat:@"--%@",TWITTERFON_FORM_BOUNDARY];
         //结束符 AaB03x--

+ 8 - 1
common/upload/RANetworkTaskDelegate.m

@@ -204,7 +204,14 @@
 }
 
 #pragma mark - NSURLSessionDataDelegate
-
+- (void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential *))completionHandler{
+    if([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]){
+        if(/*[challenge.protectionSpace.host isEqualToString:@"96.75.188.41"]*/ true){
+            NSURLCredential *credential = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust];
+            completionHandler(NSURLSessionAuthChallengeUseCredential,credential);
+        }
+    }
+}
 - (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask didReceiveResponse:(NSURLResponse *)response completionHandler:(void (^)(NSURLSessionResponseDisposition))completionHandler {
     
     NSLog(@"Delegate recv response: %@",response);