1 1.1 christos =pod 2 1.1 christos 3 1.1 christos =head1 NAME 4 1.1 christos 5 1.1.1.5 christos OCSP_REQ_CTX, 6 1.1.1.4 christos OCSP_sendreq_new, 7 1.1.1.4 christos OCSP_sendreq_nbio, 8 1.1.1.5 christos OCSP_sendreq_bio, 9 1.1.1.5 christos OCSP_REQ_CTX_i2d, 10 1.1.1.5 christos OCSP_REQ_CTX_add1_header, 11 1.1.1.4 christos OCSP_REQ_CTX_free, 12 1.1.1.4 christos OCSP_set_max_response_length, 13 1.1.1.5 christos OCSP_REQ_CTX_set1_req 14 1.1.1.4 christos - OCSP responder query functions 15 1.1 christos 16 1.1 christos =head1 SYNOPSIS 17 1.1 christos 18 1.1 christos #include <openssl/ocsp.h> 19 1.1 christos 20 1.1.1.5 christos OSSL_HTTP_REQ_CTX *OCSP_sendreq_new(BIO *io, const char *path, 21 1.1.1.5 christos const OCSP_REQUEST *req, int buf_size); 22 1.1.1.5 christos OCSP_RESPONSE *OCSP_sendreq_bio(BIO *io, const char *path, OCSP_REQUEST *req); 23 1.1 christos 24 1.1.1.5 christos The following functions have been deprecated since OpenSSL 3.0, and can be 25 1.1.1.5 christos hidden entirely by defining B<OPENSSL_API_COMPAT> with a suitable version value, 26 1.1.1.5 christos see L<openssl_user_macros(7)>: 27 1.1.1.5 christos 28 1.1.1.5 christos typedef OSSL_HTTP_REQ_CTX OCSP_REQ_CTX; 29 1.1.1.5 christos int OCSP_sendreq_nbio(OCSP_RESPONSE **presp, OSSL_HTTP_REQ_CTX *rctx); 30 1.1.1.5 christos int OCSP_REQ_CTX_i2d(OCSP_REQ_CT *rctx, const ASN1_ITEM *it, ASN1_VALUE *req); 31 1.1.1.5 christos int OCSP_REQ_CTX_add1_header(OCSP_REQ_CT *rctx, 32 1.1 christos const char *name, const char *value); 33 1.1.1.5 christos void OCSP_REQ_CTX_free(OCSP_REQ_CTX *rctx); 34 1.1.1.5 christos void OCSP_set_max_response_length(OCSP_REQ_CT *rctx, unsigned long len); 35 1.1.1.5 christos int OCSP_REQ_CTX_set1_req(OCSP_REQ_CTX *rctx, const OCSP_REQUEST *req); 36 1.1 christos 37 1.1.1.5 christos =head1 DESCRIPTION 38 1.1 christos 39 1.1.1.5 christos These functions perform an OCSP POST request / response transfer over HTTP, 40 1.1.1.5 christos using the HTTP request functions described in L<OSSL_HTTP_REQ_CTX(3)>. 41 1.1 christos 42 1.1.1.5 christos The function OCSP_sendreq_new() builds a complete B<OSSL_HTTP_REQ_CTX> structure 43 1.1.1.6 christos with the B<BIO> I<io> to be used for requests and response, the URL path I<path>, 44 1.1.1.5 christos optionally the OCSP request I<req>, and a response header maximum line length 45 1.1.1.5 christos of I<buf_size>. If I<buf_size> is zero a default value of 4KiB is used. 46 1.1.1.5 christos The I<req> may be set to NULL and provided later using OCSP_REQ_CTX_set1_req() 47 1.1.1.5 christos or L<OSSL_HTTP_REQ_CTX_set1_req(3)>. 48 1.1.1.5 christos The I<io> and I<path> arguments to OCSP_sendreq_new() correspond to the 49 1.1.1.5 christos components of the URL. 50 1.1.1.5 christos For example if the responder URL is C<http://example.com/ocspreq> the BIO 51 1.1.1.5 christos I<io> should haven been connected to host C<example.com> on port 80 and I<path> 52 1.1.1.5 christos should be set to C</ocspreq>. 53 1.1.1.5 christos 54 1.1.1.5 christos OCSP_sendreq_nbio() attempts to send the request prepared in I<rctx> 55 1.1.1.5 christos and to gather the response via HTTP, using the BIO I<io> and I<path> 56 1.1.1.5 christos that were given when calling OCSP_sendreq_new(). 57 1.1.1.5 christos If the operation gets completed it assigns the response, 58 1.1.1.5 christos a pointer to a B<OCSP_RESPONSE> structure, in I<*presp>. 59 1.1.1.5 christos The function may need to be called again if its result is -1, which indicates 60 1.1.1.5 christos L<BIO_should_retry(3)>. In such a case it is advisable to sleep a little in 61 1.1.1.5 christos between, using L<BIO_wait(3)> on the read BIO to prevent a busy loop. 62 1.1.1.5 christos 63 1.1.1.5 christos OCSP_sendreq_bio() combines OCSP_sendreq_new() with as many calls of 64 1.1.1.5 christos OCSP_sendreq_nbio() as needed and then OCSP_REQ_CTX_free(), with a 65 1.1.1.5 christos response header maximum line length 4k. It waits indefinitely on a response. 66 1.1.1.5 christos It does not support setting a timeout or adding headers and is retained 67 1.1.1.5 christos for compatibility; use L<OSSL_HTTP_transfer(3)> instead. 68 1.1.1.4 christos 69 1.1.1.5 christos OCSP_REQ_CTX_i2d(rctx, it, req) is equivalent to the following: 70 1.1 christos 71 1.1.1.5 christos OSSL_HTTP_REQ_CTX_set1_req(rctx, "application/ocsp-request", it, req) 72 1.1 christos 73 1.1.1.4 christos OCSP_REQ_CTX_set1_req(rctx, req) is equivalent to the following: 74 1.1.1.4 christos 75 1.1.1.5 christos OSSL_HTTP_REQ_CTX_set1_req(rctx, "application/ocsp-request", 76 1.1.1.5 christos ASN1_ITEM_rptr(OCSP_REQUEST), 77 1.1.1.5 christos (const ASN1_VALUE *)req) 78 1.1.1.5 christos 79 1.1.1.5 christos The deprecated type and the remaining deprecated functions 80 1.1.1.5 christos have been superseded by the following equivalents: 81 1.1.1.5 christos B<OCSP_REQ_CTX> by L<OSSL_HTTP_REQ_CTX(3)>, 82 1.1.1.5 christos OCSP_REQ_CTX_add1_header() by L<OSSL_HTTP_REQ_CTX_add1_header(3)>, 83 1.1.1.5 christos OCSP_REQ_CTX_free() by L<OSSL_HTTP_REQ_CTX_free(3)>, and 84 1.1.1.5 christos OCSP_set_max_response_length() by 85 1.1.1.5 christos L<OSSL_HTTP_REQ_CTX_set_max_response_length(3)>. 86 1.1 christos 87 1.1 christos =head1 RETURN VALUES 88 1.1 christos 89 1.1.1.5 christos OCSP_sendreq_new() returns a valid B<OSSL_HTTP_REQ_CTX> structure or NULL 90 1.1.1.5 christos if an error occurred. 91 1.1 christos 92 1.1.1.5 christos OCSP_sendreq_nbio() returns 1 for success, 0 on error, -1 if retry is needed. 93 1.1 christos 94 1.1 christos OCSP_sendreq_bio() returns the B<OCSP_RESPONSE> structure sent by the 95 1.1.1.5 christos responder or NULL if an error occurred. 96 1.1 christos 97 1.1 christos =head1 SEE ALSO 98 1.1 christos 99 1.1.1.5 christos L<OSSL_HTTP_REQ_CTX(3)>, L<OSSL_HTTP_transfer(3)>, 100 1.1 christos L<OCSP_cert_to_id(3)>, 101 1.1 christos L<OCSP_request_add1_nonce(3)>, 102 1.1 christos L<OCSP_REQUEST_new(3)>, 103 1.1 christos L<OCSP_resp_find_status(3)>, 104 1.1 christos L<OCSP_response_status(3)> 105 1.1 christos 106 1.1.1.5 christos =head1 HISTORY 107 1.1.1.5 christos 108 1.1.1.5 christos B<OCSP_REQ_CTX>, 109 1.1.1.5 christos OCSP_REQ_CTX_i2d(), 110 1.1.1.5 christos OCSP_REQ_CTX_add1_header(), 111 1.1.1.5 christos OCSP_REQ_CTX_free(), 112 1.1.1.5 christos OCSP_set_max_response_length(), 113 1.1.1.5 christos and OCSP_REQ_CTX_set1_req() 114 1.1.1.5 christos were deprecated in OpenSSL 3.0. 115 1.1.1.5 christos 116 1.1 christos =head1 COPYRIGHT 117 1.1 christos 118 1.1.1.6 christos Copyright 2015-2023 The OpenSSL Project Authors. All Rights Reserved. 119 1.1 christos 120 1.1.1.5 christos Licensed under the Apache License 2.0 (the "License"). You may not use 121 1.1 christos this file except in compliance with the License. You can obtain a copy 122 1.1 christos in the file LICENSE in the source distribution or at 123 1.1 christos L<https://www.openssl.org/source/license.html>. 124 1.1 christos 125 1.1 christos =cut 126