curl重新使用https连接会话 [英] curl to resuse https connection sessions

查看:473
本文介绍了curl重新使用https连接会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



现在每次curl进行TLS连接时,它都会再次进行握手。



我需要使用客户端与服务器的以前的连接会话ID,并在下一个请求中使用它。我尝试了下面的选项,但仍然是每次尝试的新握手

  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\\\


b $ b}

curl_easy_cleanup(curl);

有卷曲,但不能,有一些身体建议我如何用cCURL ..这样做。

解决方案

重复使用在后续请求中的curl句柄!请勿调用 curl_easy_cleanup (curl)和 curl_easy_init ()之间。


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 ..?

解决方案

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

这篇关于curl重新使用https连接会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆