Skip to content

Commit

Permalink
Merge pull request #2 from madroach/master
Browse files Browse the repository at this point in the history
add close_notify as raw SSL_shutdown
  • Loading branch information
anmonteiro authored Feb 1, 2023
2 parents c6aea13 + 2fc89e1 commit f3fe402
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
===== Unreleased =====

* add Lwt_ssl.close_notify to issue one-way SSL shutdown (#2, @madroach)

===== 1.1.3 (2018-07-30) =====

* Upgrade from Jbuilder to Dune (3b5782c).
Expand Down
2 changes: 1 addition & 1 deletion lwt_ssl.opam
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ depends: [
"dune"
"lwt" {>= "3.0.0"}
"ocaml"
"ssl" {>= "0.5.0"}
"ssl" {>= "0.5.13"}
]

build: [
Expand Down
7 changes: 7 additions & 0 deletions src/lwt_ssl.ml
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,13 @@ let ssl_shutdown (fd, s) =

let shutdown (fd, _) cmd = Lwt_unix.shutdown fd cmd

let close_notify = function
| (_, Plain) as s ->
shutdown s Unix.SHUTDOWN_SEND;
Lwt.return_true
| (fd, SSL s) ->
repeat_call fd (fun () -> Ssl.close_notify s)

let close (fd, _) = Lwt_unix.close fd

let abort (fd, _) = Lwt_unix.abort fd
Expand Down
1 change: 1 addition & 0 deletions src/lwt_ssl.mli
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ val close : socket -> unit Lwt.t
val in_channel_of_descr : ?buffer:Lwt_bytes.t -> socket -> Lwt_io.input_channel
val out_channel_of_descr : ?buffer:Lwt_bytes.t -> socket -> Lwt_io.output_channel

val close_notify : socket -> bool Lwt.t
val ssl_shutdown : socket -> unit Lwt.t

val abort : socket -> exn -> unit
Expand Down

0 comments on commit f3fe402

Please sign in to comment.