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

Error functions #119

Merged
merged 11 commits into from
Jun 1, 2023
Merged

Error functions #119

merged 11 commits into from
Jun 1, 2023

Conversation

Firgeis
Copy link
Contributor

@Firgeis Firgeis commented May 26, 2023

This PR should solve #108

  • Bindings for ERR_get_error and ERR_peek_last_error that return the raw errors as a tuple
  • Replaces the function used for exceptions with last_error so it doesn't pop the error queue inadvertently

For compatibility I have reproduced the behavior of the function used to print exceptions with the ERR_error_string_n but with the functionality of the ERR_peek_last_error function (peeks the last error)

src/ssl.mli Outdated Show resolved Hide resolved
src/ssl.mli Show resolved Hide resolved
src/ssl_stubs.c Outdated Show resolved Hide resolved
src/ssl_stubs.c Outdated Show resolved Hide resolved
Firgeis and others added 4 commits May 26, 2023 20:57
Co-authored-by: Antonio Nuno Monteiro <[email protected]>
Co-authored-by: Antonio Nuno Monteiro <[email protected]>
src/ssl.ml Outdated Show resolved Hide resolved
src/ssl.ml Outdated Show resolved Hide resolved
src/ssl_stubs.c Outdated Show resolved Hide resolved
src/ssl.mli Show resolved Hide resolved
val get_error_string : unit -> string
[@@ocaml.alert deprecated "Use [Ssl.Error.get_error] instead"]

module Error: sig
Copy link
Collaborator

Choose a reason for hiding this comment

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

@Firgeis In a follow-up PR, it'd be nice to explain in this doc that OpenSSL keeps an error queue per thread, that it gets cleaned up before every TLS operation, which can then lead to users of ocaml-ssl understanding what it means to get vs peek errors.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@anmonteiro When you say in this doc, you mean as a comment for the error module?

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah, in this .mli file.

@anmonteiro
Copy link
Collaborator

Thank you

@anmonteiro anmonteiro merged commit ff93324 into savonet:master Jun 1, 2023
@Firgeis Firgeis deleted the error-functions-binding branch June 1, 2023 22:24
anmonteiro added a commit to anmonteiro/opam-repository that referenced this pull request Jun 2, 2023
CHANGES:

- Raise an error when `Ssl.flush` isn't successful (savonet/ocaml-ssl#104, savonet/ocaml-ssl#120)
- Add an API-compatible `Ssl.Runtime_lock` module. The functions in this module
  don't release the OCaml runtime lock. While they don't allow other OCaml
  threads to run concurrently, they don't perform any copying in the underlying
  data, leading certain workloads to be faster than their counterparts that
  release the lock. (savonet/ocaml-ssl#106)
- Guarantee `Ssl.output_string` writes the whole string by retrying the
  operation with unwritten bytes (savonet/ocaml-ssl#103, savonet/ocaml-ssl#116)
- Fix calls in C stubs that need to call `ERR_clear_error` before the underlying
  OpenSSL call (savonet/ocaml-ssl#118)
- Add a module `Ssl.Error` to retrieve OpenSSL errors in a structured way (savonet/ocaml-ssl#119)
- Deprecate Ssl.{SSLv23,SSLv3,TLSv1,TLSv1_1}, which were were formally
  deprecated in March 2021 and earlier (savonet/ocaml-ssl#115).
anmonteiro added a commit to anmonteiro/opam-repository that referenced this pull request Jun 3, 2023
CHANGES:

- Raise an error when `Ssl.flush` isn't successful (savonet/ocaml-ssl#104, savonet/ocaml-ssl#120)
- Add an API-compatible `Ssl.Runtime_lock` module. The functions in this module
  don't release the OCaml runtime lock. While they don't allow other OCaml
  threads to run concurrently, they don't perform any copying in the underlying
  data, leading certain workloads to be faster than their counterparts that
  release the lock. (savonet/ocaml-ssl#106)
- Guarantee `Ssl.output_string` writes the whole string by retrying the
  operation with unwritten bytes (savonet/ocaml-ssl#103, savonet/ocaml-ssl#116)
- Fix calls in C stubs that need to call `ERR_clear_error` before the underlying
  OpenSSL call (savonet/ocaml-ssl#118)
- Add a module `Ssl.Error` to retrieve OpenSSL errors in a structured way (savonet/ocaml-ssl#119)
- Deprecate Ssl.{SSLv23,SSLv3,TLSv1,TLSv1_1}, which were were formally
  deprecated in March 2021 and earlier (savonet/ocaml-ssl#115).
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.

2 participants