Skip to content

Some culpp options should be defined as this #151

@z16166

Description

@z16166

current definitions of curlpp options:

typedef curlpp::OptionTrait<std::string, CURLOPT_CAINFO> CaInfo;
typedef curlpp::OptionTrait<std::string, CURLOPT_CAPATH> CaPath;
typedef curlpp::OptionTrait<curlpp::types::SslCtxFunctionFunctor, CURLOPT_SSL_CTX_FUNCTION> SslCtxFunction;

But the above is not working if we want to use our own certificates in memory. That is, we want to do the following:
(please refer to https://curl.se/libcurl/c/cacertinmem.html and https://curl.se/libcurl/c/CURLOPT_SSL_CTX_FUNCTION.html)

curl_easy_setopt(ch, CURLOPT_CAINFO, NULL);
curl_easy_setopt(ch, CURLOPT_CAPATH, NULL);
curl_easy_setopt(ch, CURLOPT_SSL_CTX_FUNCTION, sslctx_function);

Why it's not woking? Because NULL pointer is different with empty string, libcurl will report error if you pass it with CaInfo("") and CaPath(""). It just expects NULL pointer, not empty string.

I used the following to do it(be sure all pointers are valid during the life time of curlpp easy handle!):

typedef curlpp::OptionTrait<void *, CURLOPT_SSL_CTX_FUNCTION> SslCtxFunctionOpt;
typedef curlpp::OptionTrait<void *, CURLOPT_CAINFO> CaInfoOpt;
typedef curlpp::OptionTrait<void *, CURLOPT_CAPATH> CaPathOpt;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions