rustls / rustls-ffi

Use Rustls from any language
Other
124 stars 31 forks source link

Implement client session storage #293

Open jsha opened 1 year ago

jsha commented 1 year ago

Right now we have rustls_server_config_builder_set_persistence to store server sessions, but contrary to the comment on rustls_session_store_get_callback, we haven't actually hooked up client session storage yet.

That's handy, because rustls now has a different API for client session storage than for server session storage. So we need to implement the FFI version of that, and don't have an existing implementation we need to break.

The rough outline is: the user will give us a void *userdata and 7 function pointers, one for each of the required functions on ClientSessionStore:

kx_hint
set_kx_hint
set_tls12_session
tls12_session
remove_tls12_session
insert_tls13_ticket
take_tls13_ticket

Each of the function pointers will have a set of parameters that starts with void *userdata; this is the equivalent of &self and will be passed through on each call to these functions.

We'll then construct a Rust struct that stores these function pointers and the userdata, essentially a dispatch table. That struct will implement ClientSessionStore by passing through calls to those functions.