-int OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE* o)
- {
- int i, j, n;
- long l;
- char *s;
- unsigned char *p;
- OCSP_CERTID *cid = NULL;
- OCSP_BASICRESP *br = NULL;
- OCSP_RESPDATA *rd = NULL;
- OCSP_CERTSTATUS *cst = NULL;
- OCSP_REVOKEDINFO *rev = NULL;
- OCSP_SINGLERESP *single = NULL;
- OCSP_RESPBYTES *rb = o->responseBytes;
-
- l=ASN1_ENUMERATED_get(o->responseStatus);
- if (BIO_printf(bp,"OCSP Response Status: %s (0x%x)\n",
- ocspResponseStatus2string(l), l) <= 0) goto err;
- if (rb == NULL) return 1;
- i=OBJ_obj2nid(rb->responseType);
- if (BIO_printf(bp,"OCSP Response Bytes Response Type: %s",
- (i == NID_undef)?"UNKNOWN":OBJ_nid2sn(i)) <= 0)
- goto err;
- if (i != NID_id_pkix_OCSP_basic)
- {
- BIO_printf(bp," (unknown response type)\n");
- return 1;
- }
- p = ASN1_STRING_data(rb->response);
- i = ASN1_STRING_length(rb->response);
- if (!(d2i_OCSP_BASICRESP(&br, &p, i))) goto err;
- rd = br->tbsResponseData;
- l=ASN1_INTEGER_get(rd->version);
- if (BIO_printf(bp,"\nBasic Response Data Version: %lu (0x%lx)\n",
- l+1,l) <= 0) goto err;
- if (BIO_printf(bp,"Basic Response Data Responder Id: ") <= 0) goto err;
- i2a_OCSP_RESPID(bp, rd->responderId);
- if (BIO_printf(bp,"\nBasic Response Data Produced At: ")<=0) goto err;
- if (!ASN1_GENERALIZEDTIME_print(bp, rd->producedAt)) goto err;
- if (BIO_printf(bp,"\nBasic Response Data Responses:\n") <= 0) goto err;
- for (i = 0; i < sk_OCSP_SINGLERESP_num(rd->responses); i++)
- {
- if (! sk_OCSP_SINGLERESP_value(rd->responses, i)) continue;
- single = sk_OCSP_SINGLERESP_value(rd->responses, i);
- cid = single->certId;
- j=OBJ_obj2nid(cid->hashAlgorithm->algorithm);
- if (BIO_printf(bp," Cert Id:") <= 0) goto err;
- if (BIO_printf(bp,"\n%8sHash Algorithm: %s","",
- (j == NID_undef)?"UNKNOWN":OBJ_nid2ln(j)) <= 0)
- goto err;
- if (BIO_write(bp,"\n Issuer Name Hash: ",27) <= 0)
- goto err;
- i2a_ASN1_STRING(bp, cid->issuerNameHash, V_ASN1_OCTET_STRING);
- if (BIO_write(bp,"\n Issuer Key Hash: ",26) <= 0)
- goto err;
- i2a_ASN1_STRING(bp, cid->issuerKeyHash, V_ASN1_OCTET_STRING);
- if (BIO_write(bp,"\n Serial Number: ",24) <= 0)
- goto err;
- if (!i2a_ASN1_INTEGER(bp, cid->serialNumber))
- goto err;
- cst = single->certStatus;
- if (BIO_printf(bp,"\n Cert Status: %s (0x%x)",
- ocspCertStatus2string(cst->tag), cst->tag) <= 0)
- goto err;
- if (cst->tag == V_OCSP_CERTSTATUS_REVOKED)
- {
- rev = cst->revoked;
- if (BIO_printf(bp, "\n Revocation Time: ") <= 0)
- goto err;
- if (!ASN1_GENERALIZEDTIME_print(bp,
- rev->revocationTime))
- goto err;
- if (rev->revocationReason)
- {
- l=ASN1_ENUMERATED_get(rev->revocationReason);
- if (BIO_printf(bp,
- "\n Revocation Reason: %s (0x%x)",
- cRLReason2string(l), l) <= 0)
- goto err;
- }
- }
- if (BIO_printf(bp,"\n This Update: ") <= 0) goto err;
- if (!ASN1_GENERALIZEDTIME_print(bp, single->thisUpdate))
- goto err;
- if (single->nextUpdate)
- {
- if (BIO_printf(bp,"\n Next Update: ") <= 0)goto err;
- if (!ASN1_GENERALIZEDTIME_print(bp,single->nextUpdate))
- goto err;
- }
- if (!BIO_write(bp,"\n",1)) goto err;
- if (!OCSP_extensions_print(bp, single->singleExtensions,
- "Basic Response Single Extensions"))
- goto err;
- }
- if (!OCSP_extensions_print(bp, rd->responseExtensions,
- "Basic Response Extensions")) goto err;
- i=OBJ_obj2nid(br->signatureAlgorithm->algorithm);
- if (BIO_printf(bp,"Basic Response Signature Algorithm: %s",
- (i == NID_undef)?"UNKNOWN":OBJ_nid2ln(i)) <= 0)
- goto err;
- n=br->signature->length;
- s=(char *)br->signature->data;
- for (i=0; i<n; i++)