Hello everyone,
I am using curl methods in my project.
But before my code execution starts, there is error related to gnuTLS library
Error in GnuTLS initialization: Failed to acquire random data.
and while executing code, there is error while curl_easy_perform()
curl_easy_perform() failed: Couldn’t resolve host name
code flow:
CURL *curl;
CURLcode res;
LE_INFO("INTO:::gET uRL METHOD ");
res = curl_global_init(CURL_GLOBAL_NOTHING);
if(res == CURLE_OK)
{
curl = curl_easy_init();
if (curl)
{
res = curl_easy_setopt(curl, CURLOPT_URL,Url); //https://93.184.216.34
if (res != CURLE_OK)
{
LE_ERROR("curl_easy_setopt failed: %s", curl_easy_strerror(res));
if (res == CURLE_SSL_CACERT)
{
LE_ERROR(SSL_ERROR_HELP);
LE_ERROR(SSL_ERROR_HELP_2);
}
}
LE_INFO("INTO = Performed setopt_url ");
res = curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, PrintCallback);
if (res != CURLE_OK)
{
LE_ERROR("curl_easy_setopt failed: %s", curl_easy_strerror(res));
if (res == CURLE_SSL_CACERT)
{
LE_ERROR(SSL_ERROR_HELP);
LE_ERROR(SSL_ERROR_HELP_2);
}
}
LE_INFO("INTO = Performed setopt_writefunction ");
res = curl_easy_perform(curl);
if (res != CURLE_OK)
{
LE_ERROR("curl_easy_perform() failed: %s", curl_easy_strerror(res));
if (res == CURLE_SSL_CACERT)
{
LE_ERROR(SSL_ERROR_HELP);
LE_ERROR(SSL_ERROR_HELP_2);
}
}
LE_INFO("INTO = Performed curl_easy_perform and now cleaning ");
curl_easy_cleanup(curl);
component.cdef file :
> sources:
{ CurlBasedProjectComponent.cpp } requires: { api: { le_data.api [manual-start] } file: { /usr/lib/libcurl.so.5 /lib/ /usr/lib/libgmp.so.10 /lib/ /usr/lib/libgnutls.so.28 /lib/ /usr/lib/libhogweed.so.2 /lib/ /usr/lib/libnettle.so.4 /lib/ /lib/libz.so.1 /lib/ } }
Kindly give solution for both errors