Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare v4.0.1 #399

Merged
merged 5 commits into from
Aug 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
## Unreleased
## v4.0.1 (2021-08-06)

* change the type of `Conduit_lwt_tls.X509.default_authenticator` and
`Conduit_lwt_unix.default_ctx` to be lazy, avoiding various side-effects
(system interactions, logging) due to constructing these values at
initialisation time. (@craigfe, #395)

* Add missing `ipaddr-sexp` dependency on conduit-async (#385 @anmonteiro)
* Add missing `ipaddr-sexp` dependency on conduit-async (#385, @anmonteiro)
* Update the link of the documentation (959f57a & #398, reported by @misterfish, @zshipko, @dinosaure)
* Gitignore `opam/` even if it is a symlink (#394, @CraigFe, @avsm)
* Adapt `conduit-lwt-unix` to `tls.0.14.0` (#396, @hannesm, @dinosaure)

## v4.0.0 (2021-04-15)

Expand Down
4 changes: 2 additions & 2 deletions conduit-async.opam
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ homepage: "https://github.com/mirage/ocaml-conduit"
bug-reports: "https://github.com/mirage/ocaml-conduit/issues"
depends: [
"ocaml" {>= "4.03.0"}
"dune"
"dune" {>= "2.0"}
"core"
"uri" {>= "4.0.0"}
"ppx_here" {>= "v0.9.0"}
Expand All @@ -25,7 +25,7 @@ conflicts: [
"async_ssl" {< "v0.9.0"}
]
build: [
["dune" "subst"] {pinned}
["dune" "subst"] {dev}
["dune" "build" "-p" name "-j" jobs]
]
dev-repo: "git+https://github.com/mirage/ocaml-conduit.git"
Expand Down
6 changes: 3 additions & 3 deletions conduit-lwt-unix.opam
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ homepage: "https://github.com/mirage/ocaml-conduit"
bug-reports: "https://github.com/mirage/ocaml-conduit/issues"
depends: [
"ocaml" {>= "4.07.0"}
"dune"
"dune" {>= "2.0"}
"base-unix"
"logs"
"ppx_sexp_conv" {>="v0.13.0"}
Expand All @@ -25,11 +25,11 @@ depends: [
]
depopts: ["tls" "lwt_ssl" "launchd"]
conflicts: [
"tls" {< "0.13.0"}
"tls" {< "0.14.0"}
"ssl" {< "0.5.9"}
]
build: [
["dune" "subst"] {pinned}
["dune" "subst"] {dev}
["dune" "build" "-p" name "-j" jobs]
]
dev-repo: "git+https://github.com/mirage/ocaml-conduit.git"
Expand Down
4 changes: 2 additions & 2 deletions conduit-lwt.opam
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ homepage: "https://github.com/mirage/ocaml-conduit"
bug-reports: "https://github.com/mirage/ocaml-conduit/issues"
depends: [
"ocaml" {>= "4.03.0"}
"dune"
"dune" {>= "2.0"}
"base-unix"
"ppx_sexp_conv" {>="v0.13.0"}
"sexplib"
"conduit" {=version}
"lwt" {>= "3.0.0"}
]
build: [
["dune" "subst"] {pinned}
["dune" "subst"] {dev}
["dune" "build" "-p" name "-j" jobs]
]
dev-repo: "git+https://github.com/mirage/ocaml-conduit.git"
Expand Down
4 changes: 2 additions & 2 deletions conduit-mirage.opam
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ homepage: "https://github.com/mirage/ocaml-conduit"
bug-reports: "https://github.com/mirage/ocaml-conduit/issues"
depends: [
"ocaml" {>= "4.07.0"}
"dune"
"dune" {>= "2.0"}
"ppx_sexp_conv" {>="v0.13.0"}
"sexplib"
"uri" {>= "4.0.0"}
Expand All @@ -34,7 +34,7 @@ conflicts: [
]

build: [
["dune" "subst"] {pinned}
["dune" "subst"] {dev}
["dune" "build" "-p" name "-j" jobs]
["dune" "runtest" "-p" name] {with-test}
]
Expand Down
4 changes: 2 additions & 2 deletions conduit.opam
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ doc: "https://mirage.github.io/ocaml-conduit/"
bug-reports: "https://github.com/mirage/ocaml-conduit/issues"
depends: [
"ocaml" {>= "4.03.0"}
"dune"
"dune" {>= "2.0"}
"ppx_sexp_conv" {>="v0.13.0"}
"sexplib"
"astring"
Expand All @@ -20,7 +20,7 @@ depends: [
"ipaddr-sexp"
]
build: [
["dune" "subst"] {pinned}
["dune" "subst"] {dev}
["dune" "build" "-p" name "-j" jobs]
]
dev-repo: "git+https://github.com/mirage/ocaml-conduit.git"
Expand Down
2 changes: 1 addition & 1 deletion src/conduit-lwt-unix/conduit_lwt_tls.dummy.mli
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module Client : sig
?src:Lwt_unix.sockaddr ->
?certificates:'a ->
authenticator:X509.authenticator ->
string ->
[ `host ] Domain_name.t ->
Lwt_unix.sockaddr ->
(Lwt_unix.file_descr * Lwt_io.input_channel * Lwt_io.output_channel) Lwt.t
end
Expand Down
7 changes: 3 additions & 4 deletions src/conduit-lwt-unix/conduit_lwt_tls.real.ml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@ module X509 = struct
type authenticator = X509.Authenticator.t

let default_authenticator =
lazy
(match Ca_certs.authenticator () with
| Ok a -> a
| Error (`Msg msg) -> failwith msg)
match Ca_certs.authenticator () with
| Ok a -> a
| Error (`Msg msg) -> failwith msg
end

module Client = struct
Expand Down
4 changes: 2 additions & 2 deletions src/conduit-lwt-unix/conduit_lwt_tls.real.mli
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ module X509 : sig

type authenticator = X509.Authenticator.t

val default_authenticator : authenticator Lazy.t
val default_authenticator : authenticator
end

module Client : sig
val connect :
?src:Lwt_unix.sockaddr ->
?certificates:Tls.Config.own_cert ->
authenticator:X509.authenticator ->
string ->
[ `host ] Domain_name.t ->
Lwt_unix.sockaddr ->
(Lwt_unix.file_descr * Lwt_io.input_channel * Lwt_io.output_channel) Lwt.t
end
Expand Down
23 changes: 15 additions & 8 deletions src/conduit-lwt-unix/conduit_lwt_unix.ml
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,14 @@ let flow_of_fd fd sa =
TCP { fd; ip = Ipaddr_unix.of_inet_addr ip; port }

let default_ctx =
lazy
{
src = None;
tls_own_key = `None;
tls_authenticator = Lazy.force Conduit_lwt_tls.X509.default_authenticator;
}
{
src = None;
tls_own_key = `None;
tls_authenticator = Conduit_lwt_tls.X509.default_authenticator;
}

let init ?src ?(tls_own_key = `None)
?(tls_authenticator = Lazy.force Conduit_lwt_tls.X509.default_authenticator)
() =
?(tls_authenticator = Conduit_lwt_tls.X509.default_authenticator) () =
match src with
| None -> Lwt.return { src = None; tls_own_key; tls_authenticator }
| Some host -> (
Expand Down Expand Up @@ -264,6 +262,15 @@ let connect_with_tls_native ~ctx (`Hostname hostname, `IP ip, `Port port) =
Conduit_lwt_tls.X509.private_of_pems ~cert ~priv_key
>|= fun certificate -> Some (`Single certificate))
>>= fun certificates ->
let hostname =
try Domain_name.(host_exn (of_string_exn hostname))
with Invalid_argument msg ->
let s =
Printf.sprintf "couldn't convert %s to a [`host] Domain_name.t: %s"
hostname msg
in
invalid_arg s
in
Conduit_lwt_tls.Client.connect ?src:ctx.src ?certificates
~authenticator:ctx.tls_authenticator hostname sa
>|= fun (fd, ic, oc) ->
Expand Down
2 changes: 1 addition & 1 deletion src/conduit-lwt-unix/conduit_lwt_unix.mli
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ type ctx [@@deriving sexp_of]

(** {2 Connection and listening} *)

val default_ctx : ctx Lazy.t
val default_ctx : ctx
(** Default context that listens on all source addresses with no TLS certificate
associated with the Conduit *)

Expand Down
2 changes: 1 addition & 1 deletion tests/conduit-lwt-unix/cdtest_tls.ml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ let perform () =
let client =
`TLS (`Hostname "", `IP Ipaddr.(V6 V6.localhost), `Port port)
in
Conduit_lwt_unix.(connect ~ctx:(Lazy.force default_ctx) client)
Conduit_lwt_unix.(connect ~ctx:default_ctx client)
>>= fun (_flow, ic, oc) ->
Lwt_log.notice "Connected!" >>= fun () ->
Lwt_io.write oc "hello" >>= fun () ->
Expand Down