Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- + (NSString *)CertificateGetSubjectName: (X509 *)certificateX509 {
- NSString *issuer = nil;
- if (certificateX509 != NULL) {
- X509_NAME *issuerX509Name = X509_get_subject_name(certificateX509);
- if (issuerX509Name != NULL) {
- int nid = OBJ_txt2nid("CN"); // organization
- int index = X509_NAME_get_index_by_NID(issuerX509Name, nid, -1);
- X509_NAME_ENTRY *issuerNameEntry = X509_NAME_get_entry(issuerX509Name, index);
- if (issuerNameEntry) {
- ASN1_STRING *issuerNameASN1 = X509_NAME_ENTRY_get_data(issuerNameEntry);
- if (issuerNameASN1 != NULL) {
- unsigned char *issuerName = ASN1_STRING_data(issuerNameASN1);
- issuer = [NSString stringWithUTF8String:(char *)issuerName];
- }
- }
- }
- }
- return issuer;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement