title: OpenSSL Get Subject Alternative Name from certificate
body: <p>I'm developing an iOS app that will need to read Subject Alternative Name from an certificate (.pfx).</p>
  
  <p>Security.framework doesn't have a way to get this information, so you I'm using OpenSSL(openssl-1.0.1e) </p>
  
  <p>To read Subject Name I'm using X509_get_subject_name(certificate) and for Issuer I'm using  X509_get_issuer_name(certificate) and is working.</p>
  
  <p>The problem is the Subject Alternative Name. I can't find any function to return this information.</p>
  
  <p>Is it possible using OpenSSL to get the Subject Alternative Name? How?</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>I imported the certificate into MAC keychain. 
  On Subject Alternative Name I see NT Principal Name and RFC 822 Name.</p>
  
  <p>I tried this but it is returning NULL: </p>
  
  <pre><code>GENERAL_NAME *name = (GENERAL_NAME*)X509_get_ext_d2i(cert,NID_subject_alt_name, NULL, NULL)
  </code></pre>
  
  <p>I'm reading certificate with this:</p>
  
  <pre><code>X509 *cert;
  CFDataRef der = SecCertificateCopyData(certificate);
  const unsigned char * ptr = CFDataGetBytePtr(der);
  int len = CFDataGetLength(der);
  d2i_X509(&amp;cert,&amp;ptr,len);
  </code></pre>