title: The certificate for this server is invalid
body: <p>I know that if I use following nsurlconnectiondelegate it will be fixed</p>
  
  <blockquote>
    <p>– connection:willSendRequestForAuthenticationChallenge: –
    connection:canAuthenticateAgainstProtectionSpace</p>
  </blockquote>
  
  <p>But I am trying to use </p>
  
  <blockquote>
    <p>sendAsynchronousRequest:queue:completionHandler:</p>
  </blockquote>
  
  <p>So you don't get the callback. I looked into apple docs it say following</p>
  
  <p>If authentication is required in order to download the request, the required credentials must be specified as part of the URL. If authentication fails, or credentials are missing, the connection will attempt to continue without credentials.</p>
  
  <p>I could not figure out how to do that. When I looked up all I got is this private call</p>
  
  <blockquote>
    <p>+(void)setAllowsAnyHTTPSCertificate:(BOOL)inAllow forHost:(NSString *)inHost;</p>
  </blockquote>
  
  <p>Any idea how to do this?</p>
  
  <p>Following is the error I get</p>
  
  <blockquote>
    <p>The certificate for this server is invalid. You might be connecting to
    a server that is pretending to be “example.com=0x8b34da0
    {NSErrorFailingURLStringKey=<a href="https://example.com/test/">https://example.com/test/</a>,
    NSLocalizedRecoverySuggestion=Would you like to connect to the server
    anyway?, NSErrorFailingURLKey=<a href="https://example.com/test/">https://example.com/test/</a>,
    NSLocalizedDescription=The certificate for this server is invalid. You
    might be connecting to a server that is pretending to be “example.com”
    which could put your confidential information at risk.,
    NSUnderlyingError=0xa26c1c0 "The certificate for this server is
    invalid. You might be connecting to a server that is pretending to be
    “example.com” which could put your confidential information at risk.",
    NSURLErrorFailingURLPeerTrustErrorKey=</p>
  </blockquote>