Advertisement
Guest User

Untitled

a guest
Mar 27th, 2015
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. + (NSString *)CertificateGetSubjectName: (X509 *)certificateX509 {
  2. NSString *issuer = nil;
  3. if (certificateX509 != NULL) {
  4. X509_NAME *issuerX509Name = X509_get_subject_name(certificateX509);
  5.  
  6. if (issuerX509Name != NULL) {
  7. int nid = OBJ_txt2nid("CN"); // organization
  8. int index = X509_NAME_get_index_by_NID(issuerX509Name, nid, -1);
  9.  
  10. X509_NAME_ENTRY *issuerNameEntry = X509_NAME_get_entry(issuerX509Name, index);
  11.  
  12. if (issuerNameEntry) {
  13. ASN1_STRING *issuerNameASN1 = X509_NAME_ENTRY_get_data(issuerNameEntry);
  14.  
  15. if (issuerNameASN1 != NULL) {
  16. unsigned char *issuerName = ASN1_STRING_data(issuerNameASN1);
  17. issuer = [NSString stringWithUTF8String:(char *)issuerName];
  18. }
  19. }
  20. }
  21. }
  22. return issuer;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement