Open z16166 opened 2 years ago
Hi,
this seems to make sense, as seen by this related curl usage example. But the solution you suggested changes Curlpp interface, and will break builds of other users. (For CURLOPT_SSL_CTX_FUNCTION, I'm not sure that curlpp option need modification)
I suggest to add an NullableOptionTrait class and to add 2 news options, like :
typedef curlpp::NullableOptionTrait<std::string, CURLOPT_CAINFO> NullableCaInfoOpt;
typedef curlpp::NullableOptionTrait<std::string, CURLOPT_CAPATH> NullableCaPathOpt;
(declare CaInfoOpt and CaPathOpt as obsoletes)
NullableOptionTrait
should be able to manage a null value (add en empty ctor and a reset/clear function).
Il you're OK to achieve this, please create a PR.
Thanks for your help,
current definitions of curlpp options:
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)
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!):