Author: biurrun Date: Mon Mar 12 20:24:21 2012 New Revision: 2918 Log: pisa-cert-info: add a number of comments Modified: trunk/community-operator/client/pisa-cert-info.c Modified: trunk/community-operator/client/pisa-cert-info.c ============================================================================== --- trunk/community-operator/client/pisa-cert-info.c Mon Mar 12 20:11:48 2012 (r2917) +++ trunk/community-operator/client/pisa-cert-info.c Mon Mar 12 20:24:21 2012 (r2918) @@ -1,6 +1,6 @@ /** * @file - * This programm will extract informations of X590 certificate + * This program will extract information from an X509 certificate. * * @author Nikou Gholizadeh <Nikou.Gholizadeh@xxxxxxxxxxxxxx> */ @@ -17,6 +17,7 @@ int X509_print_fp_cop(FILE *fp, X509 *x); int print_cert_info(BIO *bp, X509 *x); +/* some helper functions to simplify output of table information */ static void topen(BIO *bp) { BIO_write(bp, "<tr><td>", 8); @@ -48,6 +49,7 @@ return ret; } +/* the function which actually extracts the certificate information */ int print_cert_info(BIO *bp, X509 *x) { long version, serial; @@ -61,6 +63,8 @@ ASN1_STRING *str = NULL; ci = x->cert_info; + + /* information about X509 certificate */ BIO_printf(bp, "<h3><strong>@TR<<Certification Data>></strong></h3>\n"); BIO_printf(bp, "<table style=\"width: 90%%; margin-left: 2.5em; "); BIO_printf(bp, "text-align: left; font-size: 0.8em;\" "); @@ -109,6 +113,7 @@ } tclose(bp); + /* print signature algorithm info, issuer info, dates */ id = OBJ_obj2nid(ci->signature->algorithm); if (BIO_printf(bp, "<tr><td>Signature Algorithm</td><td> %s</td></tr>\n", (id == NID_undef) ? "UNKNOWN" : OBJ_nid2ln(id)) <= 0) { @@ -155,6 +160,7 @@ } tclose(bp); + /* public key information */ id = OBJ_obj2nid(ci->key->algor->algorithm); if (BIO_printf(bp, "<tr><td>Public Key Algorithm</td><td>%s<br>\n", (id == NID_undef) ? "UNKNOWN" : OBJ_nid2ln(id)) <= 0) { @@ -182,9 +188,13 @@ BIO_printf(bp, "%12sUnknown Public Key:\n", ""); } tclose(bp); + + /* all basic information about an extracted certificate + * close the table */ BIO_printf(bp, "</table>\n"); EVP_PKEY_free(publickey); + /* start a new table to print info about X509v3 extensions */ number_ext = X509_get_ext_count(x); if (number_ext > 0) { BIO_printf(bp, "<h3><strong>@TR<<X509v3 extensions>></strong></h3>\n"); @@ -210,6 +220,7 @@ } } + /* print signature algorithm */ id = OBJ_obj2nid(x->sig_alg->algorithm); if (BIO_printf(bp, "<tr><td>Signature Algorithm</td><td>%s<br>\n", (id == NID_undef) ? "UNKNOWN" : OBJ_nid2ln(id)) <= 0) { @@ -242,6 +253,8 @@ ASN1_STRING_free(str); } tclose(bp); + + /* finally close the table */ BIO_write(bp, "\n</table>", 9); return ret; } -- This is the pisa developer mailing list. Please also subscribe to the main pisa list at: //www.freelists.org/list/pisa