title: How to obtain email address in X509 Certificate programmatically?
body: <p>I'm trying to get both the CN and emailAddress field from a X509 cert object in C. Currently i'm getting the CN like this:</p>
  
  <pre><code>cert_entry = X509_NAME_get_entry(X509_get_subject_name(cert), 0);
  ASN1_STRING *entryData = X509_NAME_ENTRY_get_data( cert_entry );
  ASN1_STRING_to_UTF8(&amp;CN, entryData);
  printf("%s",CN);
  </code></pre>
  
  <p>My question is how do I get the emailAddress field? I thought about parsing the string, but I'm guess there has to be a smarter way of doing that?</p>