Skip to content

Commit

Permalink
server: remove rustls_result from set_persistence
Browse files Browse the repository at this point in the history
Previously `rustls_server_config_builder_set_persistence()` returned
a `rustls_result` just to indicate if a required parameter was `NULL`.

Our API guidelines instead recommend this function do nothing and return
void for these circumstances.
  • Loading branch information
cpu committed Dec 31, 2024
1 parent c5ff8e1 commit f05e0dc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
9 changes: 6 additions & 3 deletions librustls/src/rustls.h
Original file line number Diff line number Diff line change
Expand Up @@ -2428,13 +2428,16 @@ rustls_result rustls_client_hello_select_certified_key(const struct rustls_clien
* keys and values are highly sensitive data, containing enough information
* to break the security of the connections involved.
*
* If `builder`, `get_cb`, or `put_cb` are NULL, this function will return
* immediately without doing anything.
*
* If `userdata` has been set with rustls_connection_set_userdata, it
* will be passed to the callbacks. Otherwise the userdata param passed to
* the callbacks will be NULL.
*/
rustls_result rustls_server_config_builder_set_persistence(struct rustls_server_config_builder *builder,
rustls_session_store_get_callback get_cb,
rustls_session_store_put_callback put_cb);
void rustls_server_config_builder_set_persistence(struct rustls_server_config_builder *builder,
rustls_session_store_get_callback get_cb,
rustls_session_store_put_callback put_cb);

/**
* Free a `rustls_client_cert_verifier` previously returned from
Expand Down
22 changes: 11 additions & 11 deletions librustls/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,6 @@ impl rustls_server_config {
}
}


/// Returns a `rustls_str` reference to the server name sent by the client in a server name
/// indication (SNI) extension.
///
Expand Down Expand Up @@ -722,6 +721,9 @@ impl rustls_server_config_builder {
/// keys and values are highly sensitive data, containing enough information
/// to break the security of the connections involved.
///
/// If `builder`, `get_cb`, or `put_cb` are NULL, this function will return
/// immediately without doing anything.
///
/// If `userdata` has been set with rustls_connection_set_userdata, it
/// will be passed to the callbacks. Otherwise the userdata param passed to
/// the callbacks will be NULL.
Expand All @@ -730,19 +732,17 @@ impl rustls_server_config_builder {
builder: *mut rustls_server_config_builder,
get_cb: rustls_session_store_get_callback,
put_cb: rustls_session_store_put_callback,
) -> rustls_result {
) {
ffi_panic_boundary! {
let get_cb = match get_cb {
Some(cb) => cb,
None => return rustls_result::NullParameter,
let Some(get_cb) = get_cb else {
return;
};
let put_cb = match put_cb {
Some(cb) => cb,
None => return rustls_result::NullParameter,
let Some(put_cb) = put_cb else {
return;
};
let builder = try_mut_from_ptr!(builder);
builder.session_storage = Some(Arc::new(SessionStoreBroker::new(get_cb, put_cb)));
rustls_result::Ok

try_mut_from_ptr!(builder).session_storage =
Some(Arc::new(SessionStoreBroker::new(get_cb, put_cb)));
}
}
}
Expand Down

0 comments on commit f05e0dc

Please sign in to comment.