The code below is for GENERALIZED_TIME, and doesn't handle seconds yet.
But I think you get the idea. (adopted from the perl).

time_t ASN1_GENERALIZEDTIME_2ilb(BIO *bp, ASN1_GENERALIZEDTIME *tm, int showgmt) {

        unsigned char strtime[30] ;

        time_t test = (time_t) 0;  int i ;
        if (tm->length != 15) return (time_t)-1;

        for (i = ( sizeof(time_t)*8-2) ; i>=0; i--) {           
                test += (time_t)(1 << i) ;
                strftime(strtime, 16, "%Y%m%d%H%M%SZ",gmtime(&test));
                if (strncmp(tm->data,strtime,15) < 0) 
                        test -= (time_t)(1 << i) ;
        } 
        if (bp) {
                strftime(strtime, 30, "%d-%b-%Y %H:%M:%S",localtime(&test));

                BIO_printf(bp,"%s",strtime) ; 
                if (showgmt) {
                        BIO_puts(bp," (");
                        i = ASN1_GENERALIZEDTIME_print(bp, tm) ; 
                        BIO_puts(bp,")");
                }
        }

        return test;
}
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to