]>
git.ipfire.org Git - thirdparty/openssl.git/blob - crypto/ocsp/ocsp_http.c
2 * Copyright 2001-2019 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>
12 #include "../http/http_local.h"
14 #ifndef OPENSSL_NO_OCSP
16 int OCSP_REQ_CTX_set1_req(OCSP_REQ_CTX
*rctx
, const OCSP_REQUEST
*req
)
18 return OCSP_REQ_CTX_i2d(rctx
, "application/ocsp-request",
19 ASN1_ITEM_rptr(OCSP_REQUEST
), (ASN1_VALUE
*)req
);
22 OCSP_REQ_CTX
*OCSP_sendreq_new(BIO
*io
, const char *path
, OCSP_REQUEST
*req
,
25 BIO
*req_mem
= HTTP_asn1_item2bio(ASN1_ITEM_rptr(OCSP_REQUEST
),
28 HTTP_REQ_CTX_new(io
, io
, 0 /* no HTTP proxy used */, NULL
, NULL
, path
,
29 NULL
/* headers */, "application/ocsp-request",
30 req_mem
/* may be NULL */,
31 maxline
, 0 /* default max_resp_len */,
32 0 /* no timeout, blocking indefinite */, NULL
,
38 int OCSP_sendreq_nbio(OCSP_RESPONSE
**presp
, OCSP_REQ_CTX
*rctx
)
40 *presp
= (OCSP_RESPONSE
*)
41 OCSP_REQ_CTX_nbio_d2i(rctx
, ASN1_ITEM_rptr(OCSP_RESPONSE
));
42 return *presp
!= NULL
;
45 OCSP_RESPONSE
*OCSP_sendreq_bio(BIO
*b
, const char *path
, OCSP_REQUEST
*req
)
47 OCSP_RESPONSE
*resp
= NULL
;
51 ctx
= OCSP_sendreq_new(b
, path
, req
, -1 /* default max resp line length */);
55 rv
= OCSP_sendreq_nbio(&resp
, ctx
);
57 /* this indirectly calls ERR_clear_error(): */
58 OCSP_REQ_CTX_free(ctx
);
60 return rv
== 1 ? resp
: NULL
;
62 #endif /* !defined(OPENSSL_NO_OCSP) */