Skip to content

Commit

Permalink
Merge pull request #418 from psafont/dummy-ctx
Browse files Browse the repository at this point in the history
conduit-lwt-unix: do not use directly the Ssl module
  • Loading branch information
hannesm authored Dec 15, 2022
2 parents 4282d74 + d685010 commit b3c60ca
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/conduit-lwt-unix/conduit_lwt_unix.ml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ type ctx = {
tls_own_key : tls_own_key;
tls_authenticator : Conduit_lwt_tls.X509.authenticator;
ssl_client_verify : Conduit_lwt_unix_ssl.Client.verify;
ssl_ctx : Ssl.context;
ssl_ctx : Conduit_lwt_unix_ssl.Client.context;
}

let string_of_unix_sockaddr sa =
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 @@ -161,7 +161,7 @@ val init :
?src:string ->
?tls_own_key:tls_own_key ->
?tls_authenticator:Conduit_lwt_tls.X509.authenticator ->
?ssl_ctx:Ssl.context ->
?ssl_ctx:Conduit_lwt_unix_ssl.Client.context ->
?ssl_client_verify:Conduit_lwt_unix_ssl.Client.verify ->
unit ->
ctx io
Expand Down
5 changes: 4 additions & 1 deletion src/conduit-lwt-unix/conduit_lwt_unix_ssl.dummy.ml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ module Client = struct
type verify = { hostname : bool; ip : bool }

let default_verify = { hostname = true; ip = true }
let default_ctx = `Ssl_not_available

type context = Ssl_not_available

let default_ctx = Ssl_not_available
let create_ctx ?certfile:_ ?keyfile:_ ?password:_ () = default_ctx

let connect ?(ctx = default_ctx) ?src:_ ?hostname:_ ?ip:_ ?verify:_ _sa =
Expand Down
9 changes: 6 additions & 3 deletions src/conduit-lwt-unix/conduit_lwt_unix_ssl.dummy.mli
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,20 @@ module Client : sig
type verify = { hostname : bool; ip : bool }

val default_verify : verify
val default_ctx : [ `Ssl_not_available ]

type context = Ssl_not_available

val default_ctx : context

val create_ctx :
?certfile:string ->
?keyfile:string ->
?password:(bool -> string) ->
unit ->
[ `Ssl_not_available ]
context

val connect :
?ctx:[ `Ssl_not_available ] ->
?ctx:context ->
?src:Lwt_unix.sockaddr ->
?hostname:string ->
?ip:Ipaddr.t ->
Expand Down
2 changes: 2 additions & 0 deletions src/conduit-lwt-unix/conduit_lwt_unix_ssl.real.ml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ let chans_of_fd sock =
(Lwt_ssl.get_fd sock, ic, oc)

module Client = struct
type context = Ssl.context

let create_ctx ?certfile ?keyfile ?password () =
let ctx = Ssl.create_context Ssl.SSLv23 Ssl.Client_context in
Ssl.disable_protocols ctx [ Ssl.SSLv23 ];
Expand Down
7 changes: 5 additions & 2 deletions src/conduit-lwt-unix/conduit_lwt_unix_ssl.real.mli
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ module Client : sig
type verify = { hostname : bool; ip : bool }

val default_verify : verify
val default_ctx : Ssl.context

type context = Ssl.context

val default_ctx : context

val create_ctx :
?certfile:string ->
Expand All @@ -31,7 +34,7 @@ module Client : sig
Ssl.context

val connect :
?ctx:Ssl.context ->
?ctx:context ->
?src:Lwt_unix.sockaddr ->
?hostname:string ->
?ip:Ipaddr.t ->
Expand Down

0 comments on commit b3c60ca

Please sign in to comment.