title: How to fix setAllowsAnyHTTPSCertificate private api use for Apple app submission?
body: <p>I'm using the following code to send a user login to a server, but Apple says that I'm using a private API and will reject the app. How can I resolve this?</p>
  
  <p>would replacing with <code>[NSURLRequest setAllowsAnyHTTPSCertificate:YES forHost:[url host]];</code> <code>[request setHTTPMethod:@"POST"];
  </code> be enough?</p>
  
  <pre><code>    @interface NSURLRequest (DummyInterface)
  + (BOOL)allowsAnyHTTPSCertificateForHost:(NSString*)host;
  + (void)setAllowsAnyHTTPSCertificate:(BOOL)allow forHost:(NSString*)host;
  @end
  </code></pre>
  
  <p>and my login code:</p>
  
  <pre><code>            // token url
              NSURL *url=[NSURL URLWithString:@"http://xxxxxxxx.com/api/token"];
  
              NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
  
              NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
  
              NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
              [request setURL:url];
              [request setHTTPMethod:@"POST"];
              [request setValue:postLength forHTTPHeaderField:@"Content-Length"];
              [request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
              [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
              [request setHTTPBody:postData];
  
              NSLog(@"url is %@",url),
              NSLog(@"request is %@",request),
  
  
             **[NSURLRequest setAllowsAnyHTTPSCertificate:YES forHost:[url host]];**
  </code></pre>