title: How to compare SSL certificates using AFNetworking
body: <p>In my iPhone app I'm using an <code>https</code> connection with a self-signed <code>SSL</code> certificate to download sensible data (username and password) from a server.</p>
  
  <p>This app is for private use only, it is not meant for production.</p>
  
  <p>I'm using <code>AFNetworking</code> to manage the <code>https</code> connection but, since my certificate isn't signed from a CA, in order to make it work I had to add the following to the header of the <code>AFURLConnectionOperation</code> class:</p>
  
  <pre><code>#define _AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_ 1
  </code></pre>
  
  <p>But with this my app will allow any certificate. </p>
  
  <p>Is there a way to allow only the certificate from my server maybe bundling it in the app and comparing it with the certificate provided by the server in the https connection?
  And if it were possible, would there be any significant advantage in terms of security?</p>
  
  <p>I'm very new to security and I'm kind of confused. </p>