Module s2n_tls::callbacks

source ·
Expand description

Utilities to handle passing Rust code to s2n-tls’s C callbacks.

s2n-tls uses callbacks to temporarily return control to the application and allow the application to execute custom code.

To use a callback in your application, just implement the trait for the target callback type and pass your implementation to the appropriate connection or config method. For example, you can implement ClientHelloCallback and pass that implementation to config::Builder::set_client_hello_callback() in order to execute custom logic after an s2n-tls server receives a client hello.

s2n-tls callbacks come in two flavors:

  • “sync” callbacks return an immediate result and will block the task performing the handshake until they return success or failure. See VerifyHostNameCallback as an example.
  • “async” callbacks return a Poll and should not block the task performing the handshake. They will be polled until they return Poll::Ready. Connection::waker() can be used to register the task for wakeup. See ClientHelloCallback as an example.

Structs

An implementation of ConnectionFuture which resolves the provided future and sets the config on the [connection::Connection].

Traits

A trait for the callback executed after parsing the TLS Client Hello.
The Future associated with the async connection callback.
A trait for the callback used to retrieve the monotonic time.
A trait for the callback used to verify host name(s) during X509 verification.
A trait for the callback used to retrieve the system / wall clock time.