OCSP_sendreq_new.pod 4.6 KB

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