Skip to main content
  • Home
  • login
  • Browse the archive

    swh mirror partner logo
swh logo
SoftwareHeritage
Software
Heritage
Mirror
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

  • 625e90d
  • /
  • ocsp
  • /
  • ocsp_http.c
Raw File
Permalinks

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
content badge Iframe embedding
swh:1:cnt:7a3c19c86044e38ea57b71f16dde792130ee127e
directory badge Iframe embedding
swh:1:dir:687fc5a24712953f8f4ba6078d5000b604b93caf
ocsp_http.c
/*
 * Copyright 2001-2021 The OpenSSL Project Authors. All Rights Reserved.
 *
 * Licensed under the Apache License 2.0 (the "License").  You may not use
 * this file except in compliance with the License.  You can obtain a copy
 * in the file LICENSE in the source distribution or at
 * https://www.openssl.org/source/license.html
 */

#include <openssl/ocsp.h>
#include <openssl/http.h>
#include "../http/http_local.h"

#ifndef OPENSSL_NO_OCSP

OSSL_HTTP_REQ_CTX *OCSP_sendreq_new(BIO *io, const char *path,
                                    const OCSP_REQUEST *req, int maxline)
{
    OSSL_HTTP_REQ_CTX *rctx = NULL;

    if ((rctx = OSSL_HTTP_REQ_CTX_new(io, io,
                                      maxline, 0 /* default max_resp_len */,
                                      0 /* no timeout, blocking indefinitely */,
                                      NULL, 1 /* expect_asn1 */)) == NULL)
        return NULL;

    if (!OSSL_HTTP_REQ_CTX_set_request_line(rctx, 1 /* POST */, NULL, NULL, path))
        goto err;

    if (req != NULL
        && !OSSL_HTTP_REQ_CTX_set1_req(rctx, "application/ocsp-request",
                                       ASN1_ITEM_rptr(OCSP_REQUEST),
                                       (ASN1_VALUE *)req))
        goto err;

    return rctx;

 err:
    OSSL_HTTP_REQ_CTX_free(rctx);
    return NULL;
}

int OCSP_sendreq_nbio(OCSP_RESPONSE **presp, OSSL_HTTP_REQ_CTX *rctx)
{
    *presp = (OCSP_RESPONSE *)
        OSSL_HTTP_REQ_CTX_sendreq_d2i(rctx, ASN1_ITEM_rptr(OCSP_RESPONSE));
    return *presp != NULL;
}

OCSP_RESPONSE *OCSP_sendreq_bio(BIO *b, const char *path, OCSP_REQUEST *req)
{
    OCSP_RESPONSE *resp = NULL;
    OSSL_HTTP_REQ_CTX *ctx;

    ctx = OCSP_sendreq_new(b, path, req, -1 /* default max resp line length */);
    if (ctx == NULL)
        return NULL;

    OCSP_sendreq_nbio(&resp, ctx);

    /* this indirectly calls ERR_clear_error(): */
    OSSL_HTTP_REQ_CTX_free(ctx);

    return resp;
}
#endif /* !defined(OPENSSL_NO_OCSP) */

ENEA — Copyright (C), ENEA. License: GNU AGPLv3+.
Legal notes  ::  JavaScript license information ::  Web API

back to top