Exception: Failure "No SSL or TLS support compiled into Conduit"

Hello I am learning how to use Cohttp. I wrote this code on top of “utop”

opam install cohttp-lwt-unix cohttp-async

Then run utop

#require "cohttp";;
#require "lwt";;
#require "cohttp-lwt-unix";;
open Cohttp;;
open Lwt;;
open Cohttp_lwt_unix;;
let body =
  Client.get (Uri.of_string "https://api.weather.gov/points/48.505501999717,-118.504999000172")  >>= fun (resp, body) ->
  let code = resp |> Response.status |> Code.code_of_status in
  Printf.printf "Response code: %d\n" code;
  Printf.printf "Headers: %s\n" (resp |> Response.headers |> Header.to_string);
  body |> Cohttp_lwt.Body.to_string >|= fun body ->
  Printf.printf "Body of length: %d\n" (String.length body);
  body;;
let () =
  let body = Lwt_main.run body in
  print_endline ("received body: \n" ^ body);;

But this code returns an error "Exception: Failure “No SSL or TLS support compiled into Conduit”

conduit “abstracts” over the tls implementation you can use:

Indeed, the exception could carry some further information on how to move forward.

I suggest to use opam install http-lwt-client for a HTTP1 & HTTP2 (and IPv4 & IPv6) client. But any of the above opam install will give you a cohttp-lwt-unix with TLS support.

3 Likes

Thanks hannes.

I also found one solution in this blog OCamlのCohttpで No SSL or TLS support compiled into Conduit という実行時エラーになってしまった時 - Qiita

opam install lwt_ssl
1 Like