5

I am attempting to write an application that uses libCurl to post soap requests to a secure web service. This Windows application is built against libCurl version 7.19.0 which, in turn, is built against openssl-0.9.8i. The pertinent curl related code follows:

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);
}

When I attempt to execute the URL, curl returns an CURLE_OUT_OF_MEMORY error which appears to be related to a failure to allocate an SSL context. Has anyone else encountered this problem before?

3 Answers 3

8

I had the same problem, just thought I'd add the note that rather than calling the OpenSsl export SSL_library_init directly it can be fixed by adding the flag CURL_GLOBAL_SSL to curl_global_init

Sign up to request clarification or add additional context in comments.

Comments

3

After further investigation, I found that this error was due to a failure to initialise the openSSL library by calling SSL_library_init().

Comments

0

I encountered the same symptom after upgrading to Ubuntu 16.04 as described in this answer. The solution was to Use TLS like so.

curl_easy_setopt(curl_, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2));

Apparently SSLv3 was disabled on Ubuntu 16.04.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.