OCSP_sendreq_new.pod 5.0 KB

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