title: CFNetwork SSLHandshake failed with AFNetworking 2.0, self-signed cer and [policy setAllowInvalidCertificates:YES]
body: <ul>
  <li>I'm using AFNetworking 2.   </li>
  <li>I've got a self-signed Root CA certificate in my project Bundle </li>
  <li>I'm allowing Invalid Certificates with: <code>[policy setAllowInvalidCertificates:YES];</code></li>
  <li>My url is <code>https://</code></li>
  </ul>
  
  <p>So, in theory, the self-signed certificate should be accepted. </p>
  
  <p><strong>AFSecurityPolicy</strong></p>
  
  <pre><code>AFSecurityPolicy *policy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeNone];
  [policy setAllowInvalidCertificates:YES];
  </code></pre>
  
  <p><strong>AFHTTPRequestOperationManager</strong></p>
  
  <pre><code>AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
  [manager setResponseSerializer:[AFHTTPResponseSerializer serializer]];
  [manager setRequestSerializer:[AFJSONRequestSerializer serializer]];
  [manager setSecurityPolicy:policy];
  
  [manager POST:url
     parameters:dictionary
        success:^(AFHTTPRequestOperation *operation, id responseObject) {
            // Process Response Object
            NSLog(@"JSON: %@", [responseObject description]);
  
  } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
          // Handle Error
          NSLog(@"Failure Error: %@", [error description]);
  }];
  </code></pre>
  
  <p>So nothing is apparently wrong.</p>
  
  <p>My Log:</p>
  
  <pre><code>2014-04-10 15:05:40.412 https_AF2[5548:3607] CFNetwork SSLHandshake failed (-9800)
  2014-04-10 15:05:41.092 https_AF2[5548:3607] CFNetwork SSLHandshake failed (-9800)
  2014-04-10 15:05:41.732 https_AF2[5548:3607] CFNetwork SSLHandshake failed (-9800)
  2014-04-10 15:05:41.734 https_AF2[5548:3607] NSURLConnection/CFURLConnection HTTP load failed
  (kCFStreamErrorDomainSSL, -9800)
  2014-04-10 15:05:41.736 https_AF2[5548:60b] Failure Error: Error Domain=NSURLErrorDomain 
  Code=-1200 "An SSL error has occurred and a secure connection to the server cannot be made."
  UserInfo=0x8d6af80 
  {NSErrorFailingURLStringKey=https://(myUrl)/userLogin,
  NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?,
  NSErrorFailingURLKey=https://(myUrl)/userLogin,
  NSLocalizedDescription=An SSL error has occurred and a secure connection to the server cannot be made., 
  NSUnderlyingError=0x8cb4920 "An SSL error has occurred and a secure connection to the server cannot be made."}
  </code></pre>
  
  <p>The only reason I can imagine is that the server is not properly configured. </p>
  
  <p>Any idea to solve this problem will be great!</p>