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

Fix building on OpenBSD, allow one-way shutdown #63

Merged
merged 1 commit into from
Sep 26, 2022

Conversation

madroach
Copy link

@madroach madroach commented Jun 21, 2020

  • To send an EOF over ssl you need to be able to initiate a one-way shutdown
  • Fix building against LibreSSL on OpenBSD

See also ocsigen/lwt_ssl#2 and mirage/ocaml-conduit#319

@madroach
Copy link
Author

I don't care about the close_notify change so much anymore, but please merge the compatibility changes to support LibreSSL.

@smorimoto
Copy link

@smimram @toots Could you check this as well?

src/ssl.mli Outdated
@@ -418,7 +418,11 @@ val accept : socket -> unit
(** Flush an SSL connection. *)
val flush : socket -> unit

(** Close an SSL connection. *)
(** send close notify to the peer. This is SSL_shutdown(3) *)
val close_notify : socket -> int
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API follows the general convention that the return value is never exposed, because it is quite meaningless in OCaml. A boolean indicating whehter the shutdown is finished or not (and exceptions in other cases) would be better.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it to bool.

src/ssl.mli Outdated
@@ -418,7 +418,11 @@ val accept : socket -> unit
(** Flush an SSL connection. *)
val flush : socket -> unit

(** Close an SSL connection. *)
(** send close notify to the peer. This is SSL_shutdown(3) *)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(** send close notify to the peer. This is SSL_shutdown(3) *)
(** Send close notify to the peer. This is SSL_shutdown(3). *)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

this is needed for sending EOF, aka one-way shutdown.

let rec shutdown sock =
if not (close_notify sock)
then shutdown sock
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be close_notify to prevent unbounded recursion?

Suggested change
then shutdown sock
then close_notify sock

@anmonteiro anmonteiro merged commit a346580 into savonet:master Sep 26, 2022
@anmonteiro anmonteiro mentioned this pull request Sep 26, 2022
anmonteiro added a commit to anmonteiro/opam-repository that referenced this pull request Oct 20, 2022
CHANGES:

- Add `Ssl.close_notify` to perform a one-way shutdown (savonet/ocaml-ssl#63, savonet/ocaml-ssl#96).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants