问题
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