ygrek / ocurl

OCaml bindings to libcurl
https://ygrek.org/p/ocurl
MIT License
59 stars 32 forks source link

Add support for MultiSSL mode #47

Closed nojb closed 3 years ago

nojb commented 3 years ago

Adds support for curl_global_sslset and CURLOPT_SSL_OPTIONS.

nojb commented 3 years ago

Note: the C function curl_global_sslset is bound via two different OCaml functions global_sslset and global_sslsetavail because the C API is not very natural from the point of view of OCaml.

nojb commented 3 years ago

Friendly ping.

nojb commented 3 years ago

Also I think it would be nice to have string names for ssl backends in api in parallel (it would make it easier to quickly enable new backends with old ocurl), ie to have string versions of sslset and sslsetavail

OK, I added global_sslset_str and global_sslsetavail_str for this. Thanks!

nojb commented 3 years ago

Also I think it would be nice to have string names for ssl backends in api in parallel (it would make it easier to quickly enable new backends with old ocurl), ie to have string versions of sslset and sslsetavail

OK, I added global_sslset_str and global_sslsetavail_str for this. Thanks!

Thinking again about this, do you think the version with the sum type is useful? There is no guarantee that a given backend is availble for a given libcurl version, so the only use of the sum type is really to document the "name" of the backend, which could equally well be done with a docstring...

ygrek commented 3 years ago

I can think of two usecases :

  1. code allows users to overwrite which backend to use - string is better
  2. code expected to work with specific backend - hardcodes that specific backend - a little more natural to use a variant (analogue of enum constant for C code)

so I tend to think both make sense

ygrek commented 3 years ago

Thanks!

nojb commented 3 years ago

Thanks!

Cheers, thanks!

Just for background, the motivation for this PR was that we wanted to switch to the "official" Windows binary builds https://curl.se/windows/, but these are built in MultiSSL mode with support for both OpenSSL and Secure Channel (the native Windows SSL API). The latter is simpler to use as it uses the OS-wide certificate infrastructure. But to do that, we needed a way to set the SSL backend used by ocurl :)