1=pod
2
3=head1 NAME
4
5OCSP_sendreq_new,
6OCSP_sendreq_nbio,
7OCSP_REQ_CTX_free,
8OCSP_set_max_response_length,
9OCSP_REQ_CTX_add1_header,
10OCSP_REQ_CTX_set1_req,
11OCSP_sendreq_bio,
12OCSP_REQ_CTX_i2d
13- OCSP responder query functions
14
15=head1 SYNOPSIS
16
17 #include <openssl/ocsp.h>
18
19 OCSP_REQ_CTX *OCSP_sendreq_new(BIO *io, const char *path, OCSP_REQUEST *req,
20                                int maxline);
21
22 int OCSP_sendreq_nbio(OCSP_RESPONSE **presp, OCSP_REQ_CTX *rctx);
23
24 void OCSP_REQ_CTX_free(OCSP_REQ_CTX *rctx);
25
26 void OCSP_set_max_response_length(OCSP_REQ_CTX *rctx, unsigned long len);
27
28 int OCSP_REQ_CTX_add1_header(OCSP_REQ_CTX *rctx,
29                              const char *name, const char *value);
30
31 int OCSP_REQ_CTX_set1_req(OCSP_REQ_CTX *rctx, OCSP_REQUEST *req);
32
33 OCSP_RESPONSE *OCSP_sendreq_bio(BIO *io, const char *path, OCSP_REQUEST *req);
34
35 int OCSP_REQ_CTX_i2d(OCSP_REQ_CTX *rctx, const char *content_type,
36                      const ASN1_ITEM *it, ASN1_VALUE *req);
37
38=head1 DESCRIPTION
39
40The function OCSP_sendreq_new() returns an B<OCSP_CTX> structure using the
41responder B<io>, the URL path B<path>, the OCSP request B<req> and with a
42response header maximum line length of B<maxline>. If B<maxline> is zero a
43default value of 4k is used. The OCSP request B<req> may be set to B<NULL>
44and provided later if required.
45
46OCSP_sendreq_nbio() performs nonblocking I/O on the OCSP request context
47B<rctx>. When the operation is complete it returns the response in B<*presp>.
48
49OCSP_REQ_CTX_free() frees up the OCSP context B<rctx>.
50
51OCSP_set_max_response_length() sets the maximum response length for B<rctx>
52to B<len>. If the response exceeds this length an error occurs. If not
53set a default value of 100k is used.
54
55OCSP_REQ_CTX_add1_header() adds header B<name> with value B<value> to the
56context B<rctx>. It can be called more than once to add multiple headers.
57It B<MUST> be called before any calls to OCSP_sendreq_nbio(). The B<req>
58parameter in the initial to OCSP_sendreq_new() call MUST be set to B<NULL> if
59additional headers are set.
60
61OCSP_REQ_CTX_set1_req() sets the OCSP request in B<rctx> to B<req>. This
62function should be called after any calls to OCSP_REQ_CTX_add1_header().
63OCSP_REQ_CTX_set1_req(rctx, req) is equivalent to the following:
64
65 OCSP_REQ_CTX_i2d(rctx, "application/ocsp-request",
66                        ASN1_ITEM_rptr(OCSP_REQUEST), (ASN1_VALUE *)req)
67
68OCSP_REQ_CTX_i2d() sets the request context B<rctx> to have the request
69B<req>, which has the ASN.1 type B<it>.
70The B<content_type>, if not NULL, will be included in the HTTP request.
71The function should be called after all other headers have already been added.
72
73OCSP_sendreq_bio() performs an OCSP request using the responder B<io>, the URL
74path B<path>, and the OCSP request B<req> with a response header maximum line
75length 4k. It waits indefinitely on a response.
76
77=head1 RETURN VALUES
78
79OCSP_sendreq_new() returns a valid B<OCSP_REQ_CTX> structure or B<NULL> if
80an error occurred.
81
82OCSP_sendreq_nbio() returns B<1> if the operation was completed successfully,
83B<-1> if the operation should be retried and B<0> if an error occurred.
84
85OCSP_REQ_CTX_add1_header(), OCSP_REQ_CTX_set1_req(), and OCSP_REQ_CTX_i2d()
86return B<1> for success and B<0> for failure.
87
88OCSP_sendreq_bio() returns the B<OCSP_RESPONSE> structure sent by the
89responder or B<NULL> if an error occurred.
90
91OCSP_REQ_CTX_free() and OCSP_set_max_response_length() do not return values.
92
93=head1 NOTES
94
95These functions only perform a minimal HTTP query to a responder. If an
96application wishes to support more advanced features it should use an
97alternative more complete HTTP library.
98
99Currently only HTTP POST queries to responders are supported.
100
101The arguments to OCSP_sendreq_new() correspond to the components of the URL.
102For example if the responder URL is B<http://ocsp.com/ocspreq> the BIO
103B<io> should be connected to host B<ocsp.com> on port 80 and B<path>
104should be set to B<"/ocspreq">
105
106The headers added with OCSP_REQ_CTX_add1_header() are of the form
107"B<name>: B<value>" or just "B<name>" if B<value> is B<NULL>. So to add
108a Host header for B<ocsp.com> you would call:
109
110 OCSP_REQ_CTX_add1_header(ctx, "Host", "ocsp.com");
111
112If OCSP_sendreq_nbio() indicates an operation should be retried the
113corresponding BIO can be examined to determine which operation (read or
114write) should be retried and appropriate action taken (for example a select()
115call on the underlying socket).
116
117OCSP_sendreq_bio() does not support retries and so cannot handle nonblocking
118I/O efficiently. It is retained for compatibility and its use in new
119applications is not recommended.
120
121=head1 SEE ALSO
122
123L<crypto(7)>,
124L<OCSP_cert_to_id(3)>,
125L<OCSP_request_add1_nonce(3)>,
126L<OCSP_REQUEST_new(3)>,
127L<OCSP_resp_find_status(3)>,
128L<OCSP_response_status(3)>
129
130=head1 COPYRIGHT
131
132Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved.
133
134Licensed under the OpenSSL license (the "License").  You may not use
135this file except in compliance with the License.  You can obtain a copy
136in the file LICENSE in the source distribution or at
137L<https://www.openssl.org/source/license.html>.
138
139=cut
140