oscarimonbox
3/20/2017 - 8:33 AM

Rest aceptar todos los certificados o no

Rest aceptar todos los certificados o no

en RESTMANAGER.m

si se quiere tener en cuenta el certificado, descomentar 1-6

#pragma NSURLSessionDelegate

- (void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler
{
    if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) {
#ifdef DEBUG

#endif
        // Called only for the first request, subsequent requests do no invoke this method.
        
        //1 BOOL isValid = [SecurityUtils checkTrustCertificate: challenge.protectionSpace.serverTrust];
        //2 if(isValid){
            completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]);
        //3 }
        //4 else{
        //5    completionHandler(NSURLSessionAuthChallengeCancelAuthenticationChallenge, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]);
        //6 }
    }
}