allow invalid certificates with AFNetworking

前端 未结 2 1792
逝去的感伤
逝去的感伤 2021-02-14 22:48

I have been using following code

AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc]initWithRequest:request];
operation.allowsInvalidSSLCertifica         


        
相关标签:
2条回答
  • 2021-02-14 23:31

    I solved this problem by adding following code before [operation start];

    AFSecurityPolicy *sec=[[AFSecurityPolicy alloc] init];
    [sec setAllowInvalidCertificates:YES];
    operation.securityPolicy=sec;
    

    This happened because AFHTTPRequestOperationManager is not connected to AFHTTPRequestOperation. So setting manager's security certificate can not do magic at requestOperation. So have to initialize and assign one to AFHTTPRequestOperation.

    Hope this help somebody :)

    0 讨论(0)
  • 2021-02-14 23:44

    As far as I know. It's an iOS 7 issue. Apple does not allow communication with self signed certificate websites. Unless you send the certificate to device and add as a trusted certificate list.

    Supporting comment on other question: https://stackoverflow.com/a/20251011/753603

    Couldn't find piece of documented text by Apple.

    0 讨论(0)
提交回复
热议问题