Cohttp_eio + eio-ssl?

Hello everyone :wave:

Is it possible to use cohttp-eio with eio-ssl? And are there any advantages over using ocaml-tls? Because with cohttp-lwt-unix, https support works out of the box and there is a choice between ocaml-tls and openssl.

I am asking out of curiosity :slight_smile: Tkanks ^. .^

I haven’t tried it, but probably so, because Cohttp_eio’s way of handling HTTPS is to have the programmer provide the socket manipulation function.

If you look at the client TLS example at ocaml-cohttp/cohttp-eio/examples/client_tls.ml at master · mirage/ocaml-cohttp · GitHub, I expect you could replace the contents of the https function, which uses tls-eio, with something based on eio-ssl.

ocaml-tls performs the same function and is written in pure OCaml, which many functional programmers consider nice because it is less likely to accidentally introduce some classes of bugs (notably memory safety bugs) in an OCaml library compared to a C library. Of course it is not an absolute guarantee. I am not aware of other possible pros and conses.

1 Like

Thanks for your reply! You’re right, it is possible, but it require expertise. The eio-ssl library provides some context for communication, but you should write the rest yourself. The task is to encrypt the communication flow (abstraction from Eio) using this SSL context. Unfortunately, there don’t seem to be any ready-made solutions for it.