On 22/02/2021 15:21, Laurent Dufresne via curl-library wrote:
>
> Hi everyone,
>
>  
>
> Version 7.71.0 of libcurl added few more options to enable
> user to easily use Mutual TLS.
>
> Two of them, namely CURLOPT_SSLCERT_BLOB and
> CURLOPT_SSLKEY_BLOB, take a “struct curl_blob” as
> parameter and this structure has a pointer to the data
> with type “void *”.
>
> A very common case is to have a “const char *” that point
> to a PEM formatted string and in such case one would have
> to make a non-const copy to correctly/safely use the API.
>
Why? The data isn't going to be modified. Just cast to
`void*`. The `const` is erased just like the `char` is in
this particular use case.

I suppose there could have been a similar curl_const_blob
for cases like this, which might be a clearer design. Or
https://curl.se/libcurl/c/CURLOPT_SSLCERT_BLOB.html could be
enhanced to guarantee that the blob data is not altered.

> This is even more awkward when using “CURL_BLOB_COPY”,
> because the user would theoretically have to do a copy to
> a “char *” or “char[N]” to leverage the copy.
>
I don't follow this. If you want the data to be copied, you
set `CURL_BLOB_COPY` and the data is copied, using the
length you set in the blob. If you don't, don't. What do you
need to "leverage"?

Maybe I'm missing something...

Cheers

-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.se/mail/etiquette.html

Reply via email to