web.https configuration - error: no process-level CryptoProvider available
Problem I cannot get web.https to work. I do not know if this is a bug or some kind of error from my side, as I am very new to Dioxus.
When I run:
dx serve --platform web --target wasm32
I get the following error:
Created a new certificate valid for the following names 📜│
- "localhost"is already installed in the system trust store! 👍
- "::1" The local CA is already installed in the Firefox and/or Chrome/Chromium trust store! 👍
- "127.0.0.1" The certificate is at "../certs/cert.pem" and the key at "../certs/key.pem" ✅
It will expire on 1 June 2027 🗓
thread 'tokio-runtime-worker' panicked at /home/marco/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rustls-0.23.23/src/crypto/mod.rs:249:14:
no process-level CryptoProvider available -- call CryptoProvider::install_default() before this point
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at /home/marco/.cargo/registry/src/index.crates.io-6f17d22bba15001f/dioxus-cli-0.6.3/src/serve/server.rs:163:21:
Could not receive a socket - the devtools could not boot - the port is likely already in use
(it is not an address error)
Steps To Reproduce
Steps to reproduce the behavior:
-
I have these configuration settings in
Dioxus.toml[web.https] enabled = true mkcert = true cert_path = "../certs/cert.pem" key_path = "../certs/key.pem" -
I have read the following issue (which seems to have fixed in 0.6.3) and tried to apply the suggestions found there and in the axum issue:
rustls = { version = "0.23.12", default-features = false, features = ["logging","std","tls12","ring"]}axum-server = { version = "0.7.1", features = ["tls-rustls-no-provider"] } -
I have added at the beginning of my backend
main.rs(which compiles successfully) the following: -
use rustls::crypto::ring::default_provider as rustls_provider; rustls_provider() .install_default() .expect("Failed to install rustls crypto provider");
Expected behavior
I would expect to be able to run the application over https
Screenshots
Environment:
- Dioxus version: 0.6.3
- Rust version: 1.8.5
- OS info: Linux arch 6.13.4-arch1-1 x86_64 GNU/Linux
- App platform: web
Questionnaire
I've been working on a fix: https://github.com/DioxusLabs/dioxus/pull/3764
Hi, Im also running into this issue.
What is the status on the fix? I want to use Dioxus but cant as I need https for my use case
I cloned the repo, and used this fix: https://github.com/DioxusLabs/dioxus/pull/3619/files installed it with
cargo install --path packages/cli
Then I skipped using the built in mkcert, and instead just provided dioxus with my own keys created in the same way:
keys:
mkcert -key-file ssl/key.pem -cert-file ssl/cert.pem localhost ::1 127.0.0.1
Dioxus.toml
[web.https]
enabled = true
# mkcert = true
cert_path = "ssl/cert.pem"
key_path = "ssl/key.pem"
This made it work for me
Also, running into this error on dioxus-cli 0.7.0-alpha.1. The fix #3619 was merged but was then reverted a little bit later for some reason in 5d48934
In order to enable TLS:
rustls::crypto::CryptoProvider::install_default(
rustls::crypto::aws_lc_rs::default_provider()
)
must be called before the server is started. I submitted PR #4736 with the fix and verified it works for me.