c++
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?
我遇到了同样的问题,只是认为我会添加注释,而不是直接调用OpenSsl导出SSL_library_init,它可以通过将curl_global_init标志添加到CURL_GLOBAL_SSL来解决
经过进一步调查,我发现这个错误是由于未能通过调用SSL_library_init()来初始化openSSL库所致。
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.
链接地址: http://www.djcxy.com/p/48888.html上一篇: 用PHP转义CURL @符号
下一篇: C ++