Skip to content

Commit

Permalink
Remove rustls-native-roots dependency (#110)
Browse files Browse the repository at this point in the history
There are some issues integrating with trust stores: rustls/rustls-native-certs#16,
and also some issues with regards to what gets run in forked processes:
kornelski/rust-security-framework#136.
  • Loading branch information
jsha authored Jun 25, 2021
1 parent 73f8090 commit ea868de
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 31 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ links = "crustls"
rustls = { version = "^0.19.0", features = [ "dangerous_configuration" ] }
webpki = "0.21"
libc = "0.2"
rustls-native-certs = "0.5.0"
sct = "0.6.0"
rustls-pemfile = "0.2.0"
log = "0.4.14"
Expand Down
23 changes: 3 additions & 20 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use crate::{
};

/// A client config being constructed. A builder can be modified by,
/// e.g. rustls_client_config_builder_load_native_roots. Once you're
/// e.g. rustls_client_config_builder_load_roots_from_file. Once you're
/// done configuring settings, call rustls_client_config_builder_build
/// to turn it into a *rustls_client_config. This object is not safe
/// for concurrent mutation. Under the hood, it corresponds to a
Expand Down Expand Up @@ -64,8 +64,8 @@ impl CastPtr for rustls_client_config {
/// Create a rustls_client_config_builder. Caller owns the memory and must
/// eventually call rustls_client_config_builder_build, then free the
/// resulting rustls_client_config. This starts out with no trusted roots.
/// Caller must add roots with rustls_client_config_builder_load_native_roots
/// or rustls_client_config_builder_load_roots_from_file.
/// Caller must add roots with rustls_client_config_builder_load_roots_from_file
/// or provide a custom verifier.
#[no_mangle]
pub extern "C" fn rustls_client_config_builder_new() -> *mut rustls_client_config_builder {
ffi_panic_boundary! {
Expand Down Expand Up @@ -252,23 +252,6 @@ pub extern "C" fn rustls_client_config_builder_dangerous_set_certificate_verifie
}
}

/// Add certificates from platform's native root store, using
/// https://github.com/ctz/rustls-native-certs#readme.
#[no_mangle]
pub extern "C" fn rustls_client_config_builder_load_native_roots(
config: *mut rustls_client_config_builder,
) -> rustls_result {
ffi_panic_boundary! {
let mut config: &mut ClientConfig = try_mut_from_ptr!(config);
let store = match rustls_native_certs::load_native_certs() {
Ok(store) => store,
Err(_) => return rustls_result::Io,
};
config.root_store = store;
rustls_result::Ok
}
}

/// Use the trusted root certificates from the provided store.
///
/// This replaces any trusted roots already configured with copies
Expand Down
14 changes: 4 additions & 10 deletions src/crustls.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ typedef struct rustls_client_config rustls_client_config;

/**
* A client config being constructed. A builder can be modified by,
* e.g. rustls_client_config_builder_load_native_roots. Once you're
* e.g. rustls_client_config_builder_load_roots_from_file. Once you're
* done configuring settings, call rustls_client_config_builder_build
* to turn it into a *rustls_client_config. This object is not safe
* for concurrent mutation. Under the hood, it corresponds to a
Expand Down Expand Up @@ -375,7 +375,7 @@ typedef rustls_io_result (*rustls_read_callback)(void *userdata, uint8_t *buf, s
* the implementation should return a nonzero rustls_io_result, which will be
* passed through to the caller. On POSIX systems, returning `errno` is convenient.
* On other systems, any appropriate error code works.
* It's best to make one write attempt to the network per call. Additional write will
* It's best to make one write attempt to the network per call. Additional writes will
* be triggered by subsequent calls to one of the `_write_tls` methods.
* `userdata` is set to the value provided to `rustls_*_session_set_userdata`. In most
* cases that should be a struct that contains, at a minimum, a file descriptor.
Expand Down Expand Up @@ -626,8 +626,8 @@ void rustls_client_cert_verifier_optional_free(const struct rustls_client_cert_v
* Create a rustls_client_config_builder. Caller owns the memory and must
* eventually call rustls_client_config_builder_build, then free the
* resulting rustls_client_config. This starts out with no trusted roots.
* Caller must add roots with rustls_client_config_builder_load_native_roots
* or rustls_client_config_builder_load_roots_from_file.
* Caller must add roots with rustls_client_config_builder_load_roots_from_file
* or provide a custom verifier.
*/
struct rustls_client_config_builder *rustls_client_config_builder_new(void);

Expand Down Expand Up @@ -681,12 +681,6 @@ const struct rustls_client_config *rustls_client_config_builder_build(struct rus
void rustls_client_config_builder_dangerous_set_certificate_verifier(struct rustls_client_config_builder *config,
rustls_verify_server_cert_callback callback);

/**
* Add certificates from platform's native root store, using
* https://github.com/ctz/rustls-native-certs#readme.
*/
enum rustls_result rustls_client_config_builder_load_native_roots(struct rustls_client_config_builder *config);

/**
* Use the trusted root certificates from the provided store.
*
Expand Down

0 comments on commit ea868de

Please sign in to comment.