1846
1841
unsigned char *raw,
1850
size_t left = sizeof(buffer);
1853
1846
char namebuf[32];
1855
snprintf(namebuf, sizeof(namebuf), "%s(%s)", type, name);
1857
for(i=0; i< len; i++) {
1858
snprintf(ptr, left, "%02x:", raw[i]);
1849
left = sizeof(len*3 + 1);
1850
buffer = malloc(left);
1853
snprintf(namebuf, sizeof(namebuf), "%s(%s)", type, name);
1854
for(i=0; i< len; i++) {
1855
snprintf(ptr, left, "%02x:", raw[i]);
1859
infof(data, " %s: %s\n", namebuf, buffer);
1860
push_certinfo(data, num, namebuf, buffer);
1862
infof(data, " %s: %s\n", namebuf, buffer);
1863
push_certinfo(data, num, namebuf, buffer);
1866
1865
#define print_pubkey_BN(_type, _name, _num) \
1868
1867
if (pubkey->pkey._type->_name != NULL) { \
1869
1868
int len = BN_num_bytes(pubkey->pkey._type->_name); \
1870
if(len < (int)sizeof(buf)) { \
1871
BN_bn2bin(pubkey->pkey._type->_name, (unsigned char*)buf); \
1873
pubkey_show(data, _num, #_type, #_name, (unsigned char*)buf, len); \
1869
if(len < CERTBUFFERSIZE) { \
1870
BN_bn2bin(pubkey->pkey._type->_name, (unsigned char*)bufp); \
1872
pubkey_show(data, _num, #_type, #_name, (unsigned char*)bufp, len); \
2027
(void)x509_name_oneline(X509_get_subject_name(x), buf, sizeof(buf));
2028
infof(data, "%2d Subject: %s\n",i,buf);
2029
push_certinfo(data, i, "Subject", buf);
2039
(void)x509_name_oneline(X509_get_subject_name(x), bufp, CERTBUFFERSIZE);
2040
infof(data, "%2d Subject: %s\n", i, bufp);
2041
push_certinfo(data, i, "Subject", bufp);
2031
(void)x509_name_oneline(X509_get_issuer_name(x), buf, sizeof(buf));
2032
infof(data, " Issuer: %s\n",buf);
2033
push_certinfo(data, i, "Issuer", buf);
2043
(void)x509_name_oneline(X509_get_issuer_name(x), bufp, CERTBUFFERSIZE);
2044
infof(data, " Issuer: %s\n", bufp);
2045
push_certinfo(data, i, "Issuer", bufp);
2035
2047
value = X509_get_version(x);
2036
2048
infof(data, " Version: %lu (0x%lx)\n", value+1, value);
2037
snprintf(buf, sizeof(buf), "%lx", value);
2038
push_certinfo(data, i, "Version", buf); /* hex */
2049
snprintf(bufp, CERTBUFFERSIZE, "%lx", value);
2050
push_certinfo(data, i, "Version", bufp); /* hex */
2040
2052
num=X509_get_serialNumber(x);
2041
2053
if (num->length <= 4) {
2042
2054
value = ASN1_INTEGER_get(num);
2043
2055
infof(data," Serial Number: %ld (0x%lx)\n", value, value);
2044
snprintf(buf, sizeof(buf), "%lx", value);
2056
snprintf(bufp, CERTBUFFERSIZE, "%lx", value);
2059
int left = CERTBUFFERSIZE;
2050
2063
if(num->type == V_ASN1_NEG_INTEGER)
2053
for (j=0; j<num->length; j++) {
2066
for (j=0; (j<num->length) && (left>=4); j++) {
2054
2067
/* TODO: length restrictions */
2055
2068
snprintf(ptr, 3, "%02x%c",num->data[j],
2056
2069
((j+1 == num->length)?'\n':':'));
2059
2073
if(num->length)
2060
infof(data," Serial Number: %s\n", buf);
2074
infof(data," Serial Number: %s\n", bufp);
2065
push_certinfo(data, i, "Serial Number", buf); /* hex */
2079
push_certinfo(data, i, "Serial Number", bufp); /* hex */
2067
2081
cinf = x->cert_info;
2069
j = asn1_object_dump(cinf->signature->algorithm, buf, sizeof(buf));
2083
j = asn1_object_dump(cinf->signature->algorithm, bufp, CERTBUFFERSIZE);
2071
infof(data, " Signature Algorithm: %s\n", buf);
2072
push_certinfo(data, i, "Signature Algorithm", buf);
2085
infof(data, " Signature Algorithm: %s\n", bufp);
2086
push_certinfo(data, i, "Signature Algorithm", bufp);
2075
2089
certdate = X509_get_notBefore(x);
2076
asn1_output(certdate, buf, sizeof(buf));
2077
infof(data, " Start date: %s\n", buf);
2078
push_certinfo(data, i, "Start date", buf);
2090
asn1_output(certdate, bufp, CERTBUFFERSIZE);
2091
infof(data, " Start date: %s\n", bufp);
2092
push_certinfo(data, i, "Start date", bufp);
2080
2094
certdate = X509_get_notAfter(x);
2081
asn1_output(certdate, buf, sizeof(buf));
2082
infof(data, " Expire date: %s\n", buf);
2083
push_certinfo(data, i, "Expire date", buf);
2095
asn1_output(certdate, bufp, CERTBUFFERSIZE);
2096
infof(data, " Expire date: %s\n", bufp);
2097
push_certinfo(data, i, "Expire date", bufp);
2085
j = asn1_object_dump(cinf->key->algor->algorithm, buf, sizeof(buf));
2099
j = asn1_object_dump(cinf->key->algor->algorithm, bufp, CERTBUFFERSIZE);
2087
infof(data, " Public Key Algorithm: %s\n", buf);
2088
push_certinfo(data, i, "Public Key Algorithm", buf);
2101
infof(data, " Public Key Algorithm: %s\n", bufp);
2102
push_certinfo(data, i, "Public Key Algorithm", bufp);
2091
2105
pubkey = X509_get_pubkey(x);