Hi All,
 

How can I print localised, human readable certificate dates into a null
terminated string buffer? 

I wish to present the cert dates to the user as well as the fact that the
dates are valid or invalid.

Can someone point me to a good source for X509 manipulation? 

At the moment my function reads:

void dumpCertificate(X509 *cert, char *fileName)

{
            char buf[2044];
            int ret;

            X509_NAME *subj = X509_get_subject_name(cert);
            X509_NAME *issuer = X509_get_issuer_name(cert);

            FILE *fp;
            unlink(fileName);
            fp = fopen(fileName,"w");
            if (!fp) return;


            /* check expiry dates */
            if (X509_cmp_current_time(X509_get_notBefore(cert)) >= 0) {
               fprintf(fp, "DateValid:false:Certificate date not yet
valid\n");
            }
            else if (X509_cmp_current_time(X509_get_notAfter(cert)) <= 0) {
                        fprintf(fp, "DateValid:false:Certificate date
expired\n");
            }
            else
                        fprintf(fp, "DateValid:true\n");

            /* Subject commonName */

            ret = X509_NAME_get_text_by_NID(X509_get_subject_name(cert),
NID_commonName, buf, 1024);
            fprintf(fp, "Subject.CommonName:%s\n",(ret < 1)?"":buf);


            /* Subject Organization name */
            ret = X509_NAME_get_text_by_NID(X509_get_subject_name(cert),
NID_organizationName, buf, 1024);
            fprintf(fp, "Subject.OrganizationName:%s\n",(ret < 1)?"":buf);

            /* Subject Email Address */
            ret = X509_NAME_get_text_by_NID(X509_get_subject_name(cert),
NID_pkcs9_emailAddress, buf, 1024);
            fprintf(fp, "Subject.Email:%s\n",(ret < 1)?"":buf);

 
            /* Issuer Organization name */
            ret = X509_NAME_get_text_by_NID(X509_get_issuer_name(cert),
NID_organizationName, buf, 1024);
            fprintf(fp, "Issuer.OrganizationName:%s\n",(ret < 1)?"":buf);

            fclose(fp);
}

Thanks Heaps!
Phillip.

 


-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.322 / Virus Database: 266.11.17 - Release Date: 25/05/2005
 

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to