Alternative method for NSURLRequest's private “setAllowsAnyHTTPSCertificate:forHost:”?

前端 未结 5 1135
遥遥无期
遥遥无期 2020-12-30 03:41

My iPhone application was rejected solely for using the (very safe, it seems) private method +setAllowsAnyHTTPSCertificate:forHost: for NSURLRequest. Is there a

5条回答
  •  星月不相逢
    2020-12-30 04:07

    One really stupid workaround is to make your own category method:

    @implementation NSURLRequest (IgnoreSSL)
    
    + (BOOL)allowsAnyHTTPSCertificateForHost:(NSString *)host
    {
        return YES;
    }
    
    @end
    

    This should get by Apple's private API checks, but it's still the same thing (using a private, undocumented API[1] that is liable to break at any time). Actually, it's worse since it allows everything, not just that host.

    [1]: An private API that should be made public, but a private API nevertheless.

提交回复
热议问题