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