OCSP_RESPONSE *process_responder(OCSP_REQUEST *req,
                                 const char *host, const char *path,
                                 const char *port, int use_ssl,
                                 STACK_OF(CONF_VALUE) *headers,
                                 int req_timeout)
{
    BIO *cbio = NULL;
    SSL_CTX *ctx = NULL;
    OCSP_RESPONSE *resp = NULL;
    cbio = BIO_new_connect(host);
    if (cbio == NULL) {
        BIO_printf(bio_err, "Error creating connect BIO\n");
        goto end;
    }
    if (port != NULL)
        BIO_set_conn_port(cbio, port);
    if (use_ssl == 1) {
        BIO *sbio;
        ctx = SSL_CTX_new(TLS_client_method());
        if (ctx == NULL) {
            BIO_printf(bio_err, "Error creating SSL context.\n");
            goto end;
        }
        SSL_CTX_set_mode(ctx, SSL_MODE_AUTO_RETRY);
        sbio = BIO_new_ssl(ctx, 1);
        cbio = BIO_push(sbio, cbio);
    }
    resp = query_responder(cbio, host, path, headers, req, req_timeout);
    if (resp == NULL)
        BIO_printf(bio_err, "Error querying OCSP responder\n");
 end:
    BIO_free_all(cbio);
    SSL_CTX_free(ctx);
    return resp;
}
['OCSP_RESPONSE *process_responder(OCSP_REQUEST *req,\n                                 const char *host, const char *path,\n                                 const char *port, int use_ssl,\n                                 STACK_OF(CONF_VALUE) *headers,\n                                 int req_timeout)\n{\n    BIO *cbio = NULL;\n    SSL_CTX *ctx = NULL;\n    OCSP_RESPONSE *resp = NULL;\n    cbio = BIO_new_connect(host);\n    if (cbio == NULL) {\n        BIO_printf(bio_err, "Error creating connect BIO\\n");\n        goto end;\n    }\n    if (port != NULL)\n        BIO_set_conn_port(cbio, port);\n    if (use_ssl == 1) {\n        BIO *sbio;\n        ctx = SSL_CTX_new(TLS_client_method());\n        if (ctx == NULL) {\n            BIO_printf(bio_err, "Error creating SSL context.\\n");\n            goto end;\n        }\n        SSL_CTX_set_mode(ctx, SSL_MODE_AUTO_RETRY);\n        sbio = BIO_new_ssl(ctx, 1);\n        cbio = BIO_push(sbio, cbio);\n    }\n    resp = query_responder(cbio, host, path, headers, req, req_timeout);\n    if (resp == NULL)\n        BIO_printf(bio_err, "Error querying OCSP responder\\n");\n end:\n    BIO_free_all(cbio);\n    SSL_CTX_free(ctx);\n    return resp;\n}', 'BIO *BIO_new_connect(const char *str)\n{\n    BIO *ret;\n    ret = BIO_new(BIO_s_connect());\n    if (ret == NULL)\n        return NULL;\n    if (BIO_set_conn_hostname(ret, str))\n        return ret;\n    BIO_free(ret);\n    return NULL;\n}', 'const BIO_METHOD *BIO_s_connect(void)\n{\n    return &methods_connectp;\n}', 'long BIO_ctrl(BIO *b, int cmd, long larg, void *parg)\n{\n    long ret;\n    if (b == NULL)\n        return 0;\n    if ((b->method == NULL) || (b->method->ctrl == NULL)) {\n        BIOerr(BIO_F_BIO_CTRL, BIO_R_UNSUPPORTED_METHOD);\n        return -2;\n    }\n    if (b->callback != NULL || b->callback_ex != NULL) {\n        ret = bio_call_callback(b, BIO_CB_CTRL, parg, 0, cmd, larg, 1L, NULL);\n        if (ret <= 0)\n            return ret;\n    }\n    ret = b->method->ctrl(b, cmd, larg, parg);\n    if (b->callback != NULL || b->callback_ex != NULL)\n        ret = bio_call_callback(b, BIO_CB_CTRL | BIO_CB_RETURN, parg, 0, cmd,\n                                larg, ret, NULL);\n    return ret;\n}', 'void ERR_put_error(int lib, int func, int reason, const char *file, int line)\n{\n    c_put_error(NULL, ERR_PACK(lib, func, reason), file, line);\n    ERR_add_error_data(1, "(in the FIPS module)");\n}', 'static OCSP_RESPONSE *query_responder(BIO *cbio, const char *host,\n                                      const char *path,\n                                      const STACK_OF(CONF_VALUE) *headers,\n                                      OCSP_REQUEST *req, int req_timeout)\n{\n    int fd;\n    int rv;\n    int i;\n    int add_host = 1;\n    OCSP_REQ_CTX *ctx = NULL;\n    OCSP_RESPONSE *rsp = NULL;\n    fd_set confds;\n    struct timeval tv;\n    if (req_timeout != -1)\n        BIO_set_nbio(cbio, 1);\n    rv = BIO_do_connect(cbio);\n    if ((rv <= 0) && ((req_timeout == -1) || !BIO_should_retry(cbio))) {\n        BIO_puts(bio_err, "Error connecting BIO\\n");\n        return NULL;\n    }\n    if (BIO_get_fd(cbio, &fd) < 0) {\n        BIO_puts(bio_err, "Can\'t get connection fd\\n");\n        goto err;\n    }\n    if (req_timeout != -1 && rv <= 0) {\n        FD_ZERO(&confds);\n        openssl_fdset(fd, &confds);\n        tv.tv_usec = 0;\n        tv.tv_sec = req_timeout;\n        rv = select(fd + 1, NULL, (void *)&confds, NULL, &tv);\n        if (rv == 0) {\n            BIO_puts(bio_err, "Timeout on connect\\n");\n            return NULL;\n        }\n    }\n    ctx = OCSP_sendreq_new(cbio, path, NULL, -1);\n    if (ctx == NULL)\n        return NULL;\n    for (i = 0; i < sk_CONF_VALUE_num(headers); i++) {\n        CONF_VALUE *hdr = sk_CONF_VALUE_value(headers, i);\n        if (add_host == 1 && strcasecmp("host", hdr->name) == 0)\n            add_host = 0;\n        if (!OCSP_REQ_CTX_add1_header(ctx, hdr->name, hdr->value))\n            goto err;\n    }\n    if (add_host == 1 && OCSP_REQ_CTX_add1_header(ctx, "Host", host) == 0)\n        goto err;\n    if (!OCSP_REQ_CTX_set1_req(ctx, req))\n        goto err;\n    for (;;) {\n        rv = OCSP_sendreq_nbio(&rsp, ctx);\n        if (rv != -1)\n            break;\n        if (req_timeout == -1)\n            continue;\n        FD_ZERO(&confds);\n        openssl_fdset(fd, &confds);\n        tv.tv_usec = 0;\n        tv.tv_sec = req_timeout;\n        if (BIO_should_read(cbio)) {\n            rv = select(fd + 1, (void *)&confds, NULL, NULL, &tv);\n        } else if (BIO_should_write(cbio)) {\n            rv = select(fd + 1, NULL, (void *)&confds, NULL, &tv);\n        } else {\n            BIO_puts(bio_err, "Unexpected retry condition\\n");\n            goto err;\n        }\n        if (rv == 0) {\n            BIO_puts(bio_err, "Timeout on request\\n");\n            break;\n        }\n        if (rv == -1) {\n            BIO_puts(bio_err, "Select error\\n");\n            break;\n        }\n    }\n err:\n    OCSP_REQ_CTX_free(ctx);\n    return rsp;\n}', 'int BIO_test_flags(const BIO *b, int flags)\n{\n    return (b->flags & flags);\n}', 'int BIO_puts(BIO *b, const char *buf)\n{\n    int ret;\n    size_t written = 0;\n    if ((b == NULL) || (b->method == NULL) || (b->method->bputs == NULL)) {\n        BIOerr(BIO_F_BIO_PUTS, BIO_R_UNSUPPORTED_METHOD);\n        return -2;\n    }\n    if (b->callback != NULL || b->callback_ex != NULL) {\n        ret = (int)bio_call_callback(b, BIO_CB_PUTS, buf, 0, 0, 0L, 1L, NULL);\n        if (ret <= 0)\n            return ret;\n    }\n    if (!b->init) {\n        BIOerr(BIO_F_BIO_PUTS, BIO_R_UNINITIALIZED);\n        return -2;\n    }\n    ret = b->method->bputs(b, buf);\n    if (ret > 0) {\n        b->num_write += (uint64_t)ret;\n        written = ret;\n        ret = 1;\n    }\n    if (b->callback != NULL || b->callback_ex != NULL)\n        ret = (int)bio_call_callback(b, BIO_CB_PUTS | BIO_CB_RETURN, buf, 0, 0,\n                                     0L, ret, &written);\n    if (ret > 0) {\n        if (written > INT_MAX) {\n            BIOerr(BIO_F_BIO_PUTS, BIO_R_LENGTH_TOO_LONG);\n            ret = -1;\n        } else {\n            ret = (int)written;\n        }\n    }\n    return ret;\n}', 'void OCSP_REQ_CTX_free(OCSP_REQ_CTX *rctx)\n{\n    if (!rctx)\n        return;\n    BIO_free(rctx->mem);\n    OPENSSL_free(rctx->iobuf);\n    OPENSSL_free(rctx);\n}', 'void SSL_CTX_free(SSL_CTX *a)\n{\n    int i;\n    if (a == NULL)\n        return;\n    CRYPTO_DOWN_REF(&a->references, &i, a->lock);\n    REF_PRINT_COUNT("SSL_CTX", a);\n    if (i > 0)\n        return;\n    REF_ASSERT_ISNT(i < 0);\n    X509_VERIFY_PARAM_free(a->param);\n    dane_ctx_final(&a->dane);\n    if (a->sessions != NULL)\n        SSL_CTX_flush_sessions(a, 0);\n    CRYPTO_free_ex_data(CRYPTO_EX_INDEX_SSL_CTX, a, &a->ex_data);\n    lh_SSL_SESSION_free(a->sessions);\n    X509_STORE_free(a->cert_store);\n#ifndef OPENSSL_NO_CT\n    CTLOG_STORE_free(a->ctlog_store);\n#endif\n    sk_SSL_CIPHER_free(a->cipher_list);\n    sk_SSL_CIPHER_free(a->cipher_list_by_id);\n    sk_SSL_CIPHER_free(a->tls13_ciphersuites);\n    ssl_cert_free(a->cert);\n    sk_X509_NAME_pop_free(a->ca_names, X509_NAME_free);\n    sk_X509_NAME_pop_free(a->client_ca_names, X509_NAME_free);\n    sk_X509_pop_free(a->extra_certs, X509_free);\n    a->comp_methods = NULL;\n#ifndef OPENSSL_NO_SRTP\n    sk_SRTP_PROTECTION_PROFILE_free(a->srtp_profiles);\n#endif\n#ifndef OPENSSL_NO_SRP\n    SSL_CTX_SRP_CTX_free(a);\n#endif\n#ifndef OPENSSL_NO_ENGINE\n    ENGINE_finish(a->client_cert_engine);\n#endif\n#ifndef OPENSSL_NO_EC\n    OPENSSL_free(a->ext.ecpointformats);\n    OPENSSL_free(a->ext.supportedgroups);\n#endif\n    OPENSSL_free(a->ext.alpn);\n    OPENSSL_secure_free(a->ext.secure);\n    CRYPTO_THREAD_lock_free(a->lock);\n    OPENSSL_free(a);\n}', 'static inline int CRYPTO_DOWN_REF(_Atomic int *val, int *ret, void *lock)\n{\n    *ret = atomic_fetch_sub_explicit(val, 1, memory_order_relaxed) - 1;\n    if (*ret == 0)\n        atomic_thread_fence(memory_order_acquire);\n    return 1;\n}']