title: Getting public key information from a certificate file in iOS app
body: <p>I am working on an iOS app which communicates with a remote API. This API requires me to encrypt data with a public key stored in a <code>.cer</code> file (generated by OpenSSL on a Windows machine). I have included the <code>.cer</code> file in my project and I am using the following code to get me a certificate reference (at least that's what I think I did).</p>
  
  <pre><code>NSBundle *bundle = [NSBundle bundleForClass:[self class]];
  NSData *iosTrustedCertDerData = [NSData dataWithContentsOfFile:[bundle pathForResource:@"CertName" ofType:@"cer"]];
  SecCertificateRef certificate = SecCertificateCreateWithData(NULL, (__bridge CFDataRef) iosTrustedCertDerData);
  </code></pre>
  
  <p>After that I am pretty much stuck.I have been searching the web for a while, seeing various references to openssl.h. However, openssl only seems to be available for Mac, not iOS.</p>
  
  <p>I can't stop wondering why I can't find any examples for working with certificates in your iOS app. Every time I search for certificates in iOS app, I get results explaining provisioning profiles etc. That's not what I am looking for.</p>
  
  <p>I have found RNCryptor, but as far as I can see it's a Library for encrypting/decrypting, but no support for reading keys from certificates.</p>
  
  <p>I am looking for a library (or code samples) on how to work with public keys stored in certificates, included in the application.
  Something tells me I am on the wrong track.</p>
  
  <p>When I am able to acquire the key from the certificate file, the encryption won't be a problem...hopefully.</p>
  
  <p>Any help would be highly appreciated!</p>