1、
报错如下:
curl_easy_perform() failed: SSL peer certificate or SSH remote key was not OK
解决方法:
在程序中去掉证书校验:
//取消证书校验:
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0);
/* Perform the request, res will get the return code */
res = curl_easy_perform(curl);
2、
报错:
curl_easy_perform() failed: Couldn't resolve host name
Segmentation fault
根据上面报错可以看出来,不光产生了报错,还产生段错误,导致程序异常停止。
经过仔细对比返回信息,检查出,执行 curl_easy_setopt(curl, CURLOPT_URL, url);
时,url
值为null
,不是一个有效的链接地址。
解决方法:
在程序一开始加个判断,避免出现该错误。当做暂时的解决办法。
int err;
err = strncmp(url, "http", 4); //判断是不是一个连接
if(0 != err)
{
printf("url :%s \n", url);
return -1;
}