2 * Copyright 2001-2021 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
10 #include <openssl/ocsp.h>
11 #include <openssl/http.h>
13 #ifndef OPENSSL_NO_OCSP
15 OSSL_HTTP_REQ_CTX *OCSP_sendreq_new(BIO *io, const char *path,
16 const OCSP_REQUEST *req, int buf_size)
18 OSSL_HTTP_REQ_CTX *rctx = OSSL_HTTP_REQ_CTX_new(io, io, buf_size);
24 * no bio_update_fn (and consequently no arg)
27 * no timeout (blocking indefinitely)
28 * no expected content type
29 * max_resp_len = 100 KiB
31 if (!OSSL_HTTP_REQ_CTX_set_request_line(rctx, 1 /* POST */,
34 /* by default, no extra headers */
35 if (!OSSL_HTTP_REQ_CTX_set_expected(rctx,
36 NULL /* content_type */, 1 /* asn1 */,
37 0 /* timeout */, 0 /* keep_alive */))
40 && !OSSL_HTTP_REQ_CTX_set1_req(rctx, "application/ocsp-request",
41 ASN1_ITEM_rptr(OCSP_REQUEST),
42 (const ASN1_VALUE *)req))
47 OSSL_HTTP_REQ_CTX_free(rctx);
51 OCSP_RESPONSE *OCSP_sendreq_bio(BIO *b, const char *path, OCSP_REQUEST *req)
53 OCSP_RESPONSE *resp = NULL;
54 OSSL_HTTP_REQ_CTX *ctx;
57 ctx = OCSP_sendreq_new(b, path, req, 0 /* default buf_size */);
60 mem = OSSL_HTTP_REQ_CTX_exchange(ctx);
61 /* ASN1_item_d2i_bio handles NULL bio gracefully */
62 resp = (OCSP_RESPONSE *)ASN1_item_d2i_bio(ASN1_ITEM_rptr(OCSP_RESPONSE),
65 OSSL_HTTP_REQ_CTX_free(ctx);
68 #endif /* !defined(OPENSSL_NO_OCSP) */