title: Switching from http to https. Invalid certificate
body: <p>I have an app that connects to my home routers web interface. I want to convert this to use https instead of just http.
  I was originally using <code>ASIHttpRequest</code>, but as it's no longer supported i'm switching over to <code>AFNetworking</code>.
  The problem is, whenever I try to connect, I get this <strong>error</strong> message:</p>
  
  <pre><code>_block_invoke_0220 [Line 243] ERROR: Error Domain=NSURLErrorDomain Code=-1202 "The certificate for this server is invalid. You might be connecting to a server that is pretending to be “192.168.1.1” which could put your confidential information at risk." UserInfo=0x9792ad0 {NSErrorFailingURLStringKey=https://192.168.1.1/Info.live.htm, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, NSErrorFailingURLKey=https://192.168.1.1/Info.live.htm, NSLocalizedDescription=The certificate for this server is invalid. You might be connecting to a server that is pretending to be “192.168.1.1” which could put your confidential information at risk., NSUnderlyingError=0xa6a3560 "The certificate for this server is invalid. You might be connecting to a server that is pretending to be “192.168.1.1” which could put your confidential information at risk.", NSURLErrorFailingURLPeerTrustErrorKey=&lt; SecTrustRef:
  </code></pre>
  
  <p>If I navigate to the url i safari, I get a message that Safari can't verify the identity.... and I have to click continue to carry on.
  How can I achieve this? I don't really know anything about ssl or https unfortunately.
  Here is the code i'm currently using:</p>
  
  <pre><code>NSString *urlString = @"https://192.168.1.1/";
  NSURL *url = [NSURL URLWithString:urlString];
  
  // Set authorization
  AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url];
  [httpClient setAuthorizationHeaderWithUsername:user password:pass];
  
  NSURLRequest *request = [httpClient requestWithMethod:@"POST" path:@"Info.live.htm" parameters:nil];
  AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
  [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
      NSString *responceString = [operation responseString];
      //        NSLog(@"%@",responceString);
      if ([self parseInfoLive:responceString])
          [[NSNotificationCenter defaultCenter] postNotificationName:@"downloadsComplete" object:nil];
  }
                                   failure:^(AFHTTPRequestOperation *operation, NSError *error) {
                                       NSLog(@"ERROR: %@",error.description);
                                   }];
  
  
  [operation start];
  </code></pre>