How to use NSURLConnection to connect with SSL for an untrusted cert?

后端 未结 13 1878
盖世英雄少女心
盖世英雄少女心 2020-11-22 01:29

I have the following simple code to connect to a SSL webpage

NSMutableURLRequest *urlRequest=[NSMutableURLRequest requestWithURL:url];
[ NSURLConnection send         


        
13条回答
  •  傲寒
    傲寒 (楼主)
    2020-11-22 01:43

    If you want to keep using sendSynchronousRequest i work in this solution:

    FailCertificateDelegate *fcd=[[FailCertificateDelegate alloc] init];
    
    NSURLConnection *c=[[NSURLConnection alloc] initWithRequest:request delegate:fcd startImmediately:NO];
    [c setDelegateQueue:[[NSOperationQueue alloc] init]];
    [c start];    
    NSData *d=[fcd getData];
    

    you can see it here: Objective-C SSL Synchronous Connection

提交回复
热议问题