curl to resuse https connection sessions

半城伤御伤魂 提交于 2019-12-11 10:01:57

问题


I have built curl with openssl and I am able to execute the https connection .

Now every time when curl make TLS connection it makes handshake again .

I need to make use of the client with previous connection session ID of the server and use it in next request . I have tried the below option but still its making the new handshake for every try

  curl_easy_setopt(curl, CURLOPT_URL, https://127.0.0.1);
  curl_easy_setopt(curl, CURLOPT_WRITEHEADER, headerfile);

  curl_easy_setopt(curl,CURLOPT_SSLCERTTYPE,"PEM");


  curl_easy_setopt(curl,CURLOPT_SSLCERT,"My.cert");


  curl_easy_setopt(curl,CURLOPT_SSLKEYTYPE,"PEM");

  curl_easy_setopt(curl,CURLOPT_SSLKEY,"My.Key");


  curl_easy_setopt(curl,CURLOPT_CAINFO,".");


  curl_easy_setopt(curl,CURLOPT_SSL_VERIFYPEER,1L);

  curl_easy_setopt(curl, CURLOPT_COOKIEJAR,"seesion.id") 


  res = curl_easy_perform(curl);

  if(res != CURLE_OK)
{
    fprintf(stderr, "curl_easy_perform() failed: %s\n",


 }

curl_easy_cleanup(curl);

I tried this do with curl but could not , Can some body suggest me how to do this with cCURL ..?


回答1:


Re-use the same curl handle in subsequent requests! Don't call curl_easy_cleanup(curl) and curl_easy_init() again between them.



来源:https://stackoverflow.com/questions/14141895/curl-to-resuse-https-connection-sessions

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!