mercredi 19 décembre 2018

c++ libcurl_easy SSL with Java Key Store file & Cert

I have a generated Java Key store file (.jks) which i sent to an authority which sent back a cert (.pem) file. I have tried using lib curl like

if ((status = curl_easy_setopt(curlHandle, CURLOPT_SSL_VERIFYHOST, 0)) != CURLE_OK)
{
    sprintf(err, "%s:%s: Could not set curl CURLOPT_SSL_VERIFYHOST, got err: %d\n", __FILE__, __FUNCTION__, status);
    return -1;
}
if ((status = curl_easy_setopt(curlHandle, CURLOPT_SSL_VERIFYPEER, 0)) != CURLE_OK)
{
    sprintf(err, "%s:%s: Could not set curl CURLOPT_SSL_VERIFYPEER, got err: %d\n", __FILE__, __FUNCTION__, status);
    return -1;
}
if ((status = curl_easy_setopt(curlHandle, CURLOPT_CAINFO, PEM_PATH)) != CURLE_OK)
{
    sprintf(err, "%s:%s: Could not set curl CURLOPT_CAINFO, got err: %d\n", __FILE__, __FUNCTION__, status);
    return -1;
}

When attempting to contact the server i just get a bad request error back. I am pretty sure this is because i need to setup the curl request properly so that it also uses the .jks file with the .pem file. I am not sure how I am supposed to do that and if i can even do that with a .jks file in libcurl and c++.

Thanks for the help

Aucun commentaire:

Enregistrer un commentaire