From c7a3ec93741c1d3ad93f888987133f9a55b8e579 Mon Sep 17 00:00:00 2001 From: Hannes Mehnert Date: Tue, 27 Aug 2024 19:10:33 +0200 Subject: [PATCH] adapt to tls 1.0.0 --- http-mirage-client.opam | 1 + src/http_mirage_client.ml | 17 ++++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/http-mirage-client.opam b/http-mirage-client.opam index 041591b..c5b0d50 100644 --- a/http-mirage-client.opam +++ b/http-mirage-client.opam @@ -22,6 +22,7 @@ depends: [ "mirage-crypto-rng" {with-test} "mirage-time-unix" {with-test & >= "3.0.0"} "h2" {>= "0.10.0"} + "tls" {>= "1.0.0"} ] build: [ ["dune" "subst"] {dev} diff --git a/src/http_mirage_client.ml b/src/http_mirage_client.ml index 1c55ae2..637f556 100644 --- a/src/http_mirage_client.ml +++ b/src/http_mirage_client.ml @@ -383,7 +383,8 @@ let single_request let tls_config ?tls_config ?config authenticator user's_authenticator = lazy - (match tls_config with + (let ( let* ) = Result.bind in + match tls_config with | Some cfg -> Ok (`Custom cfg) | None -> ( let alpn_protocols = @@ -391,12 +392,14 @@ let tls_config ?tls_config ?config authenticator user's_authenticator = | None -> ["h2"; "http/1.1"] | Some (`H2 _) -> ["h2"] | Some (`HTTP_1_1 _) -> ["http/1.1"] in - match authenticator, user's_authenticator with - | Ok authenticator, None -> - Ok (`Default (Tls.Config.client ~alpn_protocols ~authenticator ())) - | _, Some authenticator -> - Ok (`Default (Tls.Config.client ~alpn_protocols ~authenticator ())) - | (Error _ as err), None -> err)) + let* authenticator = + match authenticator, user's_authenticator with + | Ok authenticator, None -> Ok authenticator + | _, Some authenticator -> Ok authenticator + | (Error _ as err), None -> err + in + let* cfg = Tls.Config.client ~alpn_protocols ~authenticator () in + Ok (`Default cfg))) let resolve_location ~uri ~location = match String.split_on_char '/' location with