curl-library
Re: use libcurl in a customized environment
Date: Wed, 14 Dec 2016 21:15:52 +0100
On Wed, Dec 14, 2016 at 10:44:54AM -0500, Fan Zhang wrote:
> I’m trying to use libcurl as a HTTP client in a special environment (i.e. Intel SGX for those who cares) where it can not access OS services and can only access socket via a customized shim. I haven’t dived very deep into the source code yet, but I’m wondering how hard it would be to config / refactor libcurl so that I can 1) extract only the HTTP part of it and 2) have it use customized socket APIs? Any suggestion where to start?
libcurl should be almost able to do both without change, depending on how
customized the socket API is. All but HTTP support can be compiled away using
the right combination of configure flags (I run some "size-reduced HTTP only"
autobuilds to make sure it stays working). There are various callback functions
that can be set to use some custom functions instead of standard socket ones
(e.g. CURLOPT_OPENSOCKETFUNCTION, CURLOPT_CLOSESOCKETFUNCTION,
CURLOPT_SOCKOPTFUNCTION). If you use the multi interface, you can supply your
own poll function. Reading and writing to the socket will still be done using
read/recv and write/send, so if those have to be customized you'll have to
replace the corresponding sread/swrite macros at the source level, but that
should be pretty easy. And if you already have a customized SSL library and
restrict operations to https only, you might be able to get away with no source
changes at all.
>>> Dan
-------------------------------------------------------------------
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2016-12-14