title: SSL Pinning with AFNetworking
body: <p>In my app I'm using https and a self-signed SSL certificate to secure the connection between my client and the server.</p>
  
  <p>I was trying to have the AFNetworking library do SSL Pinning on a copy of my certificate bundled in the app.</p>
  
  <p>In the <code>AFURLConnectionOperation</code> header I defined both:</p>
  
  <pre><code>#define _AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_ =1
  #define _AFNETWORKING_PIN_SSL_CERTIFICATES_ =1
  </code></pre>
  
  <p>And before calling the <code>start</code> on my <code>AFJSONRequestOperation</code> I set the <code>SSLPinningMode</code> property to <code>AFSSLPinningModeCertificate</code>.</p>
  
  <p>But when trying to perform a JSON request I keep getting the following error:</p>
  
  <pre><code>Error Domain=NSURLErrorDomain Code=-1012 "The operation couldn’t be completed. 
  (NSURLErrorDomain error -1012.)" UserInfo=0x758f120 
  {NSErrorFailingURLKey=https://mydomain.com,
  NSErrorFailingURLStringKey=https://mydomain.com}
  </code></pre>
  
  <p>In the <code>AFURLConnectionOperation</code> header I read that the SSL Pinning works with .cer certificates but in my self-hosted OS X webserver I have a .crt certificate.</p>
  
  <p>Is this the problem? Is there a way to make AFNetworking work with .crt?</p>
  
  <p>On a windows box I converted my .crt to .cer and tried to bundle that into my app but I still get the same error. Should I try to switch the .crt file with the newly created .cer even on the server side?</p>