1*e71b7053SJung-uk Kim=pod 2*e71b7053SJung-uk Kim 3*e71b7053SJung-uk Kim=head1 NAME 4*e71b7053SJung-uk Kim 5*e71b7053SJung-uk KimOCSP_sendreq_new, OCSP_sendreq_nbio, OCSP_REQ_CTX_free, 6*e71b7053SJung-uk KimOCSP_set_max_response_length, OCSP_REQ_CTX_add1_header, 7*e71b7053SJung-uk KimOCSP_REQ_CTX_set1_req, OCSP_sendreq_bio - OCSP responder query functions 8*e71b7053SJung-uk Kim 9*e71b7053SJung-uk Kim=head1 SYNOPSIS 10*e71b7053SJung-uk Kim 11*e71b7053SJung-uk Kim #include <openssl/ocsp.h> 12*e71b7053SJung-uk Kim 13*e71b7053SJung-uk Kim OCSP_REQ_CTX *OCSP_sendreq_new(BIO *io, const char *path, OCSP_REQUEST *req, 14*e71b7053SJung-uk Kim int maxline); 15*e71b7053SJung-uk Kim 16*e71b7053SJung-uk Kim int OCSP_sendreq_nbio(OCSP_RESPONSE **presp, OCSP_REQ_CTX *rctx); 17*e71b7053SJung-uk Kim 18*e71b7053SJung-uk Kim void OCSP_REQ_CTX_free(OCSP_REQ_CTX *rctx); 19*e71b7053SJung-uk Kim 20*e71b7053SJung-uk Kim void OCSP_set_max_response_length(OCSP_REQ_CTX *rctx, unsigned long len); 21*e71b7053SJung-uk Kim 22*e71b7053SJung-uk Kim int OCSP_REQ_CTX_add1_header(OCSP_REQ_CTX *rctx, 23*e71b7053SJung-uk Kim const char *name, const char *value); 24*e71b7053SJung-uk Kim 25*e71b7053SJung-uk Kim int OCSP_REQ_CTX_set1_req(OCSP_REQ_CTX *rctx, OCSP_REQUEST *req); 26*e71b7053SJung-uk Kim 27*e71b7053SJung-uk Kim OCSP_RESPONSE *OCSP_sendreq_bio(BIO *io, const char *path, OCSP_REQUEST *req, 28*e71b7053SJung-uk Kim int maxline); 29*e71b7053SJung-uk Kim 30*e71b7053SJung-uk Kim=head1 DESCRIPTION 31*e71b7053SJung-uk Kim 32*e71b7053SJung-uk KimThe function OCSP_sendreq_new() returns an B<OCSP_CTX> structure using the 33*e71b7053SJung-uk Kimresponder B<io>, the URL path B<path>, the OCSP request B<req> and with a 34*e71b7053SJung-uk Kimresponse header maximum line length of B<maxline>. If B<maxline> is zero a 35*e71b7053SJung-uk Kimdefault value of 4k is used. The OCSP request B<req> may be set to B<NULL> 36*e71b7053SJung-uk Kimand provided later if required. 37*e71b7053SJung-uk Kim 38*e71b7053SJung-uk KimOCSP_sendreq_nbio() performs non-blocking I/O on the OCSP request context 39*e71b7053SJung-uk KimB<rctx>. When the operation is complete it returns the response in B<*presp>. 40*e71b7053SJung-uk Kim 41*e71b7053SJung-uk KimOCSP_REQ_CTX_free() frees up the OCSP context B<rctx>. 42*e71b7053SJung-uk Kim 43*e71b7053SJung-uk KimOCSP_set_max_response_length() sets the maximum response length for B<rctx> 44*e71b7053SJung-uk Kimto B<len>. If the response exceeds this length an error occurs. If not 45*e71b7053SJung-uk Kimset a default value of 100k is used. 46*e71b7053SJung-uk Kim 47*e71b7053SJung-uk KimOCSP_REQ_CTX_add1_header() adds header B<name> with value B<value> to the 48*e71b7053SJung-uk Kimcontext B<rctx>. It can be called more than once to add multiple headers. 49*e71b7053SJung-uk KimIt B<MUST> be called before any calls to OCSP_sendreq_nbio(). The B<req> 50*e71b7053SJung-uk Kimparameter in the initial to OCSP_sendreq_new() call MUST be set to B<NULL> if 51*e71b7053SJung-uk Kimadditional headers are set. 52*e71b7053SJung-uk Kim 53*e71b7053SJung-uk KimOCSP_REQ_CTX_set1_req() sets the OCSP request in B<rctx> to B<req>. This 54*e71b7053SJung-uk Kimfunction should be called after any calls to OCSP_REQ_CTX_add1_header(). 55*e71b7053SJung-uk Kim 56*e71b7053SJung-uk KimOCSP_sendreq_bio() performs an OCSP request using the responder B<io>, the URL 57*e71b7053SJung-uk Kimpath B<path>, the OCSP request B<req> and with a response header maximum line 58*e71b7053SJung-uk Kimlength of B<maxline>. If B<maxline> is zero a default value of 4k is used. 59*e71b7053SJung-uk Kim 60*e71b7053SJung-uk Kim=head1 RETURN VALUES 61*e71b7053SJung-uk Kim 62*e71b7053SJung-uk KimOCSP_sendreq_new() returns a valid B<OCSP_REQ_CTX> structure or B<NULL> if 63*e71b7053SJung-uk Kiman error occurred. 64*e71b7053SJung-uk Kim 65*e71b7053SJung-uk KimOCSP_sendreq_nbio() returns B<1> if the operation was completed successfully, 66*e71b7053SJung-uk KimB<-1> if the operation should be retried and B<0> if an error occurred. 67*e71b7053SJung-uk Kim 68*e71b7053SJung-uk KimOCSP_REQ_CTX_add1_header() and OCSP_REQ_CTX_set1_req() return B<1> for success 69*e71b7053SJung-uk Kimand B<0> for failure. 70*e71b7053SJung-uk Kim 71*e71b7053SJung-uk KimOCSP_sendreq_bio() returns the B<OCSP_RESPONSE> structure sent by the 72*e71b7053SJung-uk Kimresponder or B<NULL> if an error occurred. 73*e71b7053SJung-uk Kim 74*e71b7053SJung-uk KimOCSP_REQ_CTX_free() and OCSP_set_max_response_length() do not return values. 75*e71b7053SJung-uk Kim 76*e71b7053SJung-uk Kim=head1 NOTES 77*e71b7053SJung-uk Kim 78*e71b7053SJung-uk KimThese functions only perform a minimal HTTP query to a responder. If an 79*e71b7053SJung-uk Kimapplication wishes to support more advanced features it should use an 80*e71b7053SJung-uk Kimalternative more complete HTTP library. 81*e71b7053SJung-uk Kim 82*e71b7053SJung-uk KimCurrently only HTTP POST queries to responders are supported. 83*e71b7053SJung-uk Kim 84*e71b7053SJung-uk KimThe arguments to OCSP_sendreq_new() correspond to the components of the URL. 85*e71b7053SJung-uk KimFor example if the responder URL is B<http://ocsp.com/ocspreq> the BIO 86*e71b7053SJung-uk KimB<io> should be connected to host B<ocsp.com> on port 80 and B<path> 87*e71b7053SJung-uk Kimshould be set to B<"/ocspreq"> 88*e71b7053SJung-uk Kim 89*e71b7053SJung-uk KimThe headers added with OCSP_REQ_CTX_add1_header() are of the form 90*e71b7053SJung-uk Kim"B<name>: B<value>" or just "B<name>" if B<value> is B<NULL>. So to add 91*e71b7053SJung-uk Kima Host header for B<ocsp.com> you would call: 92*e71b7053SJung-uk Kim 93*e71b7053SJung-uk Kim OCSP_REQ_CTX_add1_header(ctx, "Host", "ocsp.com"); 94*e71b7053SJung-uk Kim 95*e71b7053SJung-uk KimIf OCSP_sendreq_nbio() indicates an operation should be retried the 96*e71b7053SJung-uk Kimcorresponding BIO can be examined to determine which operation (read or 97*e71b7053SJung-uk Kimwrite) should be retried and appropriate action taken (for example a select() 98*e71b7053SJung-uk Kimcall on the underlying socket). 99*e71b7053SJung-uk Kim 100*e71b7053SJung-uk KimOCSP_sendreq_bio() does not support retries and so cannot handle non-blocking 101*e71b7053SJung-uk KimI/O efficiently. It is retained for compatibility and its use in new 102*e71b7053SJung-uk Kimapplications is not recommended. 103*e71b7053SJung-uk Kim 104*e71b7053SJung-uk Kim=head1 SEE ALSO 105*e71b7053SJung-uk Kim 106*e71b7053SJung-uk KimL<crypto(7)>, 107*e71b7053SJung-uk KimL<OCSP_cert_to_id(3)>, 108*e71b7053SJung-uk KimL<OCSP_request_add1_nonce(3)>, 109*e71b7053SJung-uk KimL<OCSP_REQUEST_new(3)>, 110*e71b7053SJung-uk KimL<OCSP_resp_find_status(3)>, 111*e71b7053SJung-uk KimL<OCSP_response_status(3)> 112*e71b7053SJung-uk Kim 113*e71b7053SJung-uk Kim=head1 COPYRIGHT 114*e71b7053SJung-uk Kim 115*e71b7053SJung-uk KimCopyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. 116*e71b7053SJung-uk Kim 117*e71b7053SJung-uk KimLicensed under the OpenSSL license (the "License"). You may not use 118*e71b7053SJung-uk Kimthis file except in compliance with the License. You can obtain a copy 119*e71b7053SJung-uk Kimin the file LICENSE in the source distribution or at 120*e71b7053SJung-uk KimL<https://www.openssl.org/source/license.html>. 121*e71b7053SJung-uk Kim 122*e71b7053SJung-uk Kim=cut 123