双向认证:
1.服务器回验证客户端上报的证书
2.客户端回验证服务器的证书
而证书一般分为:1.受信任的根证书,2不受信任的根证书。
但是由于各种限制不想在libcurl中增加openssl,那么使用默认的winssl也可以完成以上两种证书的双向认证,以下是亲测代码:
static int http_write(char* data, size_t size, size_t nmemb, std::string* writerData)
{
unsigned long sizes = size * nmemb;
if (writerData == NULL)
return-1;
writerData->append(data, sizes);
return sizes;
}
int main_curl(void)
{
CURL* curl;
CURLcode res = CURLE_OK;
const char* pPassphrase = NULL; //password for private key
static const char* pCACertFile = "C:\\ca.crt"; //CA root certificat
static const char* pCertFile = "C:\\client.p12"; //client certificate
static const char* pKeyName = "C:\\client.key"; // private.key
static const char* pHeaderFile = "dumpit";
const char* pKeyType;
const char* pE