if (!ASN1_UTCTIME_print(bp,X509_get_notAfter(x))) goto err;
if (!ASN1_TIME_print(bp,X509_get_notAfter(x))) goto err;
int X509_print(bp,x)BIO *bp;X509 *x;	{	long l;	int ret=0,i,j,n;	char *m=NULL,*s;	X509_CINF *ci;	ASN1_INTEGER *bs;	EVP_PKEY *pkey=NULL;	char *neg;	X509_EXTENSION *ex;	ASN1_STRING *str=NULL;	ci=x->cert_info;	if (BIO_write(bp,"Certificate:\n",13) <= 0) goto err;	if (BIO_write(bp,"    Data:\n",10) <= 0) goto err;	l=X509_get_version(x);	if (BIO_printf(bp,"%8sVersion: %lu (0x%lx)\n","",l+1,l) <= 0) goto err;	if (BIO_write(bp,"        Serial Number:",22) <= 0) goto err;	bs=X509_get_serialNumber(x);	if (bs->length <= 4)		{		l=ASN1_INTEGER_get(bs);		if (l < 0)			{			l= -l;			neg="-";			}		else			neg="";		if (BIO_printf(bp," %s%lu (%s0x%lx)\n",neg,l,neg,l) <= 0)			goto err;		}	else		{		neg=(bs->type == V_ASN1_NEG_INTEGER)?" (Negative)":"";		if (BIO_printf(bp,"\n%12s%s","",neg) <= 0) goto err;		for (i=0; i<bs->length; i++)			{			if (BIO_printf(bp,"%02x%c",bs->data[i],				((i+1 == bs->length)?'\n':':')) <= 0)				goto err;			}		}	i=OBJ_obj2nid(ci->signature->algorithm);	if (BIO_printf(bp,"%8sSignature Algorithm: %s\n","",		(i == NID_undef)?"UNKNOWN":OBJ_nid2ln(i)) <= 0)		goto err;	if (BIO_write(bp,"        Issuer: ",16) <= 0) goto err;	if (!X509_NAME_print(bp,X509_get_issuer_name(x),16)) goto err;	if (BIO_write(bp,"\n        Validity\n",18) <= 0) goto err;	if (BIO_write(bp,"            Not Before: ",24) <= 0) goto err;	if (!ASN1_UTCTIME_print(bp,X509_get_notBefore(x))) goto err;	if (BIO_write(bp,"\n            Not After : ",25) <= 0) goto err;	if (!ASN1_UTCTIME_print(bp,X509_get_notAfter(x))) goto err;	if (BIO_write(bp,"\n        Subject: ",18) <= 0) goto err;	if (!X509_NAME_print(bp,X509_get_subject_name(x),16)) goto err;	if (BIO_write(bp,"\n        Subject Public Key Info:\n",34) <= 0)		goto err;	i=OBJ_obj2nid(ci->key->algor->algorithm);	if (BIO_printf(bp,"%12sPublic Key Algorithm: %s\n","",		(i == NID_undef)?"UNKNOWN":OBJ_nid2ln(i)) <= 0) goto err;	pkey=X509_get_pubkey(x);	if (pkey == NULL)		{		BIO_printf(bp,"%12sUnable to load Public Key\n","");		}	else#ifndef NO_RSA	if (pkey->type == EVP_PKEY_RSA)		{		BIO_printf(bp,"%12sRSA Public Key: (%d bit)\n","",		BN_num_bits(pkey->pkey.rsa->n));		RSA_print(bp,pkey->pkey.rsa,16);		}	else#endif#ifndef NO_DSA	if (pkey->type == EVP_PKEY_DSA)		{		BIO_printf(bp,"%12sDSA Public Key:\n","");		DSA_print(bp,pkey->pkey.dsa,16);		}	else#endif		BIO_printf(bp,"%12sUnknown Public Key:\n","");	EVP_PKEY_free(pkey);	n=X509_get_ext_count(x);	if (n > 0)		{		BIO_printf(bp,"%8sX509v3 extensions:\n","");		for (i=0; i<n; i++)			{			int data_type,pack_type;			ASN1_OBJECT *obj;			ex=X509_get_ext(x,i);			if (BIO_printf(bp,"%12s","") <= 0) goto err;			obj=X509_EXTENSION_get_object(ex);			i2a_ASN1_OBJECT(bp,obj);			j=X509_EXTENSION_get_critical(ex);			if (BIO_printf(bp,": %s\n%16s",j?"critical":"","") <= 0)				goto err;			pack_type=X509v3_pack_type_by_OBJ(obj);			data_type=X509v3_data_type_by_OBJ(obj);						if (pack_type == X509_EXT_PACK_STRING)				{				if (X509v3_unpack_string(					&str,data_type,					X509_EXTENSION_get_data(ex)) == NULL)					{					/* hmm... */					goto err;					}				if (	(data_type == V_ASN1_IA5STRING) ||					(data_type == V_ASN1_PRINTABLESTRING) ||					(data_type == V_ASN1_T61STRING))					{					if (BIO_write(bp,(char *)str->data,							str->length) <= 0)						goto err;					}				else if (data_type == V_ASN1_BIT_STRING)					{					BIO_printf(bp,"0x");					for (j=0; j<str->length; j++)						{						BIO_printf(bp,"%02X",							str->data[j]);						}					}				}			else				{				ASN1_OCTET_STRING_print(bp,ex->value);				}			if (BIO_write(bp,"\n",1) <= 0) goto err;			}		}	i=OBJ_obj2nid(x->sig_alg->algorithm);	if (BIO_printf(bp,"%4sSignature Algorithm: %s","",		(i == NID_undef)?"UNKNOWN":OBJ_nid2ln(i)) <= 0) goto err;	n=x->signature->length;	s=(char *)x->signature->data;	for (i=0; i<n; i++)		{		if ((i%18) == 0)			if (BIO_write(bp,"\n        ",9) <= 0) goto err;		if (BIO_printf(bp,"%02x%s",(unsigned char)s[i],			((i+1) == n)?"":":") <= 0) goto err;		}	if (BIO_write(bp,"\n",1) != 1) goto err;	ret=1;err:	if (str != NULL) ASN1_STRING_free(str);	if (m != NULL) Free((char *)m);	return(ret);	}