通过https发布时出现"CURLE_OUT_OF_MEMORY"错误

Jon*_*ein 5 c++ https curl openssl

我正在尝试编写一个使用libCurl将SOAP请求发布到安全Web服务的应用程序.此Windows应用程序是针对libCurl版本7.19.0构建的,而后者又是针对openssl-0.9.8i构建的.相关的卷曲相关代码如下:

FILE *input_file = fopen(current->post_file_name.c_str(), "rb");
FILE *output_file = fopen(current->results_file_name.c_str(), "wb");
if(input_file && output_file)
{
    struct curl_slist *header_opts = 0;
    CURLcode rcd;

    header_opts = curl_slist_append(header_opts, "Content-Type: application/soap+xml; charset=utf8");
    curl_easy_reset(curl_handle);
    curl_easy_setopt(curl_handle, CURLOPT_NOPROGRESS, 1);
    curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, output_file);
    curl_easy_setopt(curl_handle, CURLOPT_READDATA, input_file);
    curl_easy_setopt(curl_handle, CURLOPT_URL, fs_service_url);
    curl_easy_setopt(curl_handle, CURLOPT_POST, 1);
    curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, header_opts);
    rcd = curl_easy_perform(curl_handle);
    if(rcd != 0)
    {
        current->curl_result = rcd;
        current->curl_error = curl_easy_strerror(rcd);
    }
    curl_slist_free_all(header_opts);
}

当我尝试执行URL时,curl返回CURLE_OUT_OF_MEMORY错误,该错误似乎与分配SSL上下文失败有关.有没有其他人遇到过这个问题?

Gle*_*len 8

我有同样的问题,只是想我添加注释,而不是直接调用OpenSsl导出SSL_library_init它可以通过添加标志CURL_GLOBAL_SSL到curl_global_init修复


Jon*_*ein 3

经过进一步调查,我发现这个错误是由于调用SSL_library_init()初始化openSSL库失败造成的。