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

How I use CryptoProvider::install_default() ? #1938

Closed
incker opened this issue May 3, 2024 · 7 comments
Closed

How I use CryptoProvider::install_default() ? #1938

incker opened this issue May 3, 2024 · 7 comments

Comments

@incker
Copy link

incker commented May 3, 2024

Hello, I receive panic
PanicInfo { payload: Any { .. }, message: Some(no process-level CryptoProvider available -- call CryptoProvider::install_default() before this point), location: Location { file: "/home/incker/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rustls-0.23.5/src/crypto/mod.rs", line: 260, col: 14 }, can_unwind: true, force_no_backtrace: false }

But there is no example how to use CryptoProvider::install_default()

Cargo.toml:
rustls = {version = "0.23.5", default-features = false, features = ["std"]}

If I remove default-features = false it requires
Please enable the 'bindgen' feature on aws-lc-rs or aws-lc-sys.For more information, see the aws-lc-rs User Guide: https://aws.github.io/aws-lc-rs/index.html

but adding this:
aws-lc-rs = {version = "1.7.0", features = ["bindgen"]}
requires:
/usr/include/stdio.h:27:10: fatal error: 'bits/libc-header-start.h' file not found
thread 'main' panicked at /home/builder/.cargo/registry/src/index.crates.io-6f17d22bba15001f/aws-lc-sys-0.15.0/builder/bindgen.rs:155:10:
Unable to generate bindings.: ClangDiagnostic("/usr/include/stdio.h:27:10: fatal error: 'bits/libc-header-start.h' file not found\n")

And i haven't found package gcc-multilib for arm-buildroot-linux-musleabihf ((

Forward thank you!

@ctz
Copy link
Member

ctz commented May 3, 2024

But there is no example how to use CryptoProvider::install_default()

See https://docs.rs/rustls/latest/rustls/index.html#crate-features

/usr/include/stdio.h:27:10: fatal error: 'bits/libc-header-start.h' file not found

https://rust-lang.github.io/rust-bindgen/requirements.html#requirements aside from that, yes, you will need a working sysroot for the target and to tell bindgen where it is.

@KarstenB
Copy link

KarstenB commented May 8, 2024

Ok, maybe it is just me, but the simplest solution boils down to using the ring feature of rustls:

cargo add rustls --features ring

And then, early in your main fn call:

rustls::crypto::ring::default_provider().install_default().expect("Failed to install rustls crypto provider");

Correct?

@incker
Copy link
Author

incker commented May 18, 2024

Installing just gcc-multilib helped me
Thanks for everyone!

@lcmgh
Copy link

lcmgh commented Jul 18, 2024

Am I correct that one also has to set rustls::crypto::aws_lc_rs::default_provider().install_default(); for each test that involves rustls?

@cpu
Copy link
Member

cpu commented Jul 18, 2024

@lcmgh The answer to that depends. If your crate only activates one of the ring or aws_lc_rs features of Rustls then no, the tests can use the config constructors that assume the default without you needing to explicitly set it. If however, your crate activates both features, yes, your tests will need to install a default explicitly or stop using the constructors that assume a default is set.

@lcmgh
Copy link

lcmgh commented Jul 18, 2024

rustls = { version = "0.23.5" }

In that case might it be that another dep of me brings rustls with ring and aws_lc_rs into the game because I have not enabled those features explicitly.

@cpu
Copy link
Member

cpu commented Jul 19, 2024

@lcmgh You can likely get to the bottom of that using cargo tree --edges features. Rustls uses aws_lc_rs by default, so you're probably looking for a dependency that is activating ring in addition.

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

No branches or pull requests

6 participants