5 static void print_attribute_value(A2C_OPEN_TYPE
* value
)
9 if (_A2C_PrintToMemory(value
->objectPtr
, value
->functionPtr
, &string
) == A2C_ERROR_Success
)
11 printf("%s\n", string
);
17 static void print_name_email_addresses(Cert_Name
* name
)
21 for (counter
= 0;counter
< name
->u
.rdnSequence
.count
;++counter
)
25 for (rdn_counter
= 0;rdn_counter
< name
->u
.rdnSequence
.array
[counter
].count
;++rdn_counter
)
27 Cert_AttributeTypeAndValue
* attribute
= &(name
->u
.rdnSequence
.array
[counter
].array
[rdn_counter
]);
29 if (_A2C_OIDS_EQUAL(&(attribute
->type
), Cert_emailAddress
.id
))
31 print_attribute_value(&attribute
->value
);
37 static void print_subject_alt_name_email_addresses(Cert_Certificate
* certificate
)
41 for (counter
= 0;counter
< certificate
->toBeSigned
.extensions
.count
;++counter
)
43 if (_A2C_OIDS_EQUAL(&certificate
->toBeSigned
.extensions
.array
[counter
].extnID
, &CertImpl_id_ce_subjectAltName
))
45 CertImpl_GeneralNames
* names
= NULL
;
46 A2C_ERROR err
= A2C_ERROR_Success
;
47 int names_counter
= 0;
51 &CertImpl_GeneralNames_descriptor
,
54 certificate
->toBeSigned
.extensions
.array
[counter
].extnValue
.data
,
55 certificate
->toBeSigned
.extensions
.array
[counter
].extnValue
.length
57 if (err
< A2C_ERROR_Success
)
62 for (names_counter
= 0;names_counter
< names
->count
;++names_counter
)
64 if (names
->array
[names_counter
].index
== CertImpl_GeneralName_rfc822Name_index
)
66 printf("%s\n", names
->array
[names_counter
].u
.rfc822Name
.string
);
70 (void) A2C_Free_CertImpl_GeneralNames(names
);
75 int main(int argc
, char** argv
)
77 Cert_Certificate
* certificate
= NULL
;
79 certificate
= read_certificate_from_file(argv
[1]);
80 if (certificate
!= NULL
)
82 print_name_email_addresses(&certificate
->toBeSigned
.subject
);
83 print_subject_alt_name_email_addresses(certificate
);