使用libcurl& SSL [英] Using libcurl & SSL

查看:121
本文介绍了使用libcurl& SSL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现有关这个主题的信息真的很少。我已经有一个dll使用libcurl成功的帖子。

I've found there is really very little information around on this topic. I already have a dll making successful posts using libcurl.

我编译libcurl与openssl的ssl功能。

I've compiled libcurl with openssl for ssl functionality.

    curl_easy_setopt(handle, CURLOPT_ERRORBUFFER, errorBuffer);

    //curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER , 1);
    //curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST , 1);
    //curl_easy_setopt(curl, CURLOPT_CAINFO , "./ca.cert");

    curl_easy_setopt(handle, CURLOPT_POSTFIELDS, cParam); 
    curl_easy_setopt(handle, CURLOPT_POSTFIELDSIZE, strlen(cParam));
    curl_easy_setopt(handle, CURLOPT_FOLLOWLOCATION, 1);
    curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, Request::writer);   
    curl_easy_setopt(handle, CURLOPT_WRITEDATA, &buffer); 
    curl_easy_setopt(handle, CURLOPT_URL, cURL);

我对以前做过的人的问题,以使SSL工作(只要证书存在)?还是更复杂?

My question to those who've done this before, is it as easy as just adding those lines above to get SSL to work (as long as the certificate exists)? Or is it more complicated?

有趣的是,我不完全确定SSL是如何工作的。我从来没有使用过它。我需要在我的应用程序中存储密钥,并与每个请求一起发送吗?无论如何我的主要问题是第一。先谢谢。

The funny thing is I'm not completely sure how SSL works. I've never worked with it before. Do I need to store a key in my application and send it with each request? Anyway my main question was the first. Thank you in advance.

推荐答案

是的,很简单。只要确保您拥有的ca.cert文件是一个真正的CA证书,可以验证您的服务器的证书。

Yes, it is that simple. Just make sure that the "ca.cert" file you have is a true CA cert that can verify your server's certificate.

这篇关于使用libcurl& SSL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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