118
118
OPENSSL_free(rctx);
121
int OCSP_REQ_CTX_set1_req(OCSP_REQ_CTX *rctx, OCSP_REQUEST *req)
123
static const char req_hdr[] =
124
"Content-Type: application/ocsp-request\r\n"
125
"Content-Length: %d\r\n\r\n";
126
if (BIO_printf(rctx->mem, req_hdr, i2d_OCSP_REQUEST(req, NULL)) <= 0)
128
if (i2d_OCSP_REQUEST_bio(rctx->mem, req) <= 0)
130
rctx->state = OHS_ASN1_WRITE;
131
rctx->asn1_len = BIO_get_mem_data(rctx->mem, NULL);
135
int OCSP_REQ_CTX_add1_header(OCSP_REQ_CTX *rctx,
136
const char *name, const char *value)
140
if (BIO_puts(rctx->mem, name) <= 0)
144
if (BIO_write(rctx->mem, ": ", 2) != 2)
146
if (BIO_puts(rctx->mem, value) <= 0)
149
if (BIO_write(rctx->mem, "\r\n", 2) != 2)
121
154
OCSP_REQ_CTX *OCSP_sendreq_new(BIO *io, char *path, OCSP_REQUEST *req,
124
static char post_hdr[] = "POST %s HTTP/1.0\r\n"
125
"Content-Type: application/ocsp-request\r\n"
126
"Content-Length: %d\r\n\r\n";
157
static const char post_hdr[] = "POST %s HTTP/1.0\r\n";
128
159
OCSP_REQ_CTX *rctx;
129
160
rctx = OPENSSL_malloc(sizeof(OCSP_REQ_CTX));
130
rctx->state = OHS_FIRSTLINE;
161
rctx->state = OHS_ERROR;
131
162
rctx->mem = BIO_new(BIO_s_mem());
134
166
rctx->iobuflen = maxline;
136
168
rctx->iobuflen = OCSP_MAX_LINE_LEN;
137
169
rctx->iobuf = OPENSSL_malloc(rctx->iobuflen);
141
if (BIO_printf(rctx->mem, post_hdr, path,
142
i2d_OCSP_REQUEST(req, NULL)) <= 0)
144
rctx->state = OHS_ERROR;
147
if (i2d_OCSP_REQUEST_bio(rctx->mem, req) <= 0)
149
rctx->state = OHS_ERROR;
152
rctx->state = OHS_ASN1_WRITE;
153
rctx->asn1_len = BIO_get_mem_data(rctx->mem, NULL);
175
if (BIO_printf(rctx->mem, post_hdr, path) <= 0)
178
if (req && !OCSP_REQ_CTX_set1_req(rctx, req))
373
399
case OHS_ASN1_HEADER:
374
/* Now reading ASN1 header: can read at least 6 bytes which
375
* is more than enough for any valid ASN1 SEQUENCE header
400
/* Now reading ASN1 header: can read at least 2 bytes which
401
* is enough for ASN1 SEQUENCE header and either length field
402
* or at least the length of the length field.
377
404
n = BIO_get_mem_data(rctx->mem, &p);
381
408
/* Check it is an ASN1 SEQUENCE */