rust-cryptoki
rust-cryptoki copied to clipboard
Wasm support
Cannot compile cryptoki-sys to wasm target
Related to: Cannot compile dependency: could not find Library in libloading #1641
When I build, watch & serve a Rust WASM app with cryptoki, its dependency cryptoki-sys raise a compilation error.
The error is:
# cargo check --target wasm32-unknown-unknown
Checking ...
Checking cryptoki-sys v0.1.7 (registry `custom-regsitry`)
error[E0433]: failed to resolve: could not find `Library` in `libloading`
--> /root/.cargo/registry/src/custom-regsitry-url/cryptoki-sys-0.1.7/src/bindings/generic.rs:2164:37
|
2164 | let library = ::libloading::Library::new(path)?;
| ^^^^^^^ could not find `Library` in `libloading`
error[E0412]: cannot find type `Library` in crate `libloading`
--> /root/.cargo/registry/src/custom-regsitry-url/cryptoki-sys-0.1.7/src/bindings/generic.rs:1634:30
|
1634 | __library: ::libloading::Library,
| ^^^^^^^ not found in `libloading`
error[E0412]: cannot find type `Library` in crate `libloading`
--> /root/.cargo/registry/src/custom-regsitry-url/cryptoki-sys-0.1.7/src/bindings/generic.rs:2169:31
|
2169 | L: Into<::libloading::Library>,
| ^^^^^^^ not found in `libloading`
Some errors have detailed explanations: E0412, E0433.
For more information about an error, try `rustc --explain E0412`.
error: could not compile `cryptoki-sys` (lib) due to 3 previous errors
Steps To Reproduce
- Make sure the
wasm32-unknown-unknowntarget for rust is installedrustup target add wasm32-unknown-unknown- (if you are using a custom Rust toolchain, add the wasm32 component into your
rust/toolchains/$custom-toolchain/components/folder
- (if you are using a custom Rust toolchain, add the wasm32 component into your
- Install the dioxus command line allowing you to compile your rust app to wasm target
cargo install dioxus-clidx --help
- Create a rust application using the default dioxus template:
dx create, and select the following options:- If you are working in an offline workspace:
download/unzipthe dioxus-template- run instead:
dx create --template dioxus-template-main
- If
$USERnot found ->export USER=any, the value do not matter
- If you are working in an offline workspace:
# dx create --template dioxus-template-main
[WARN] You appear to be creating a Dioxus project from scratch; we will use the default config
[WARN] Favorite `dioxus-template-main` not found in config, using it as a local path: dioxus-template-main
...
✔ What platform are you targeting? · web
✔ Should the application use the dioxus router? · true
✔ How do you want to create CSS? · Vanilla
...
Expected behavior
Being able to compile after running dx serve:
Project Reloaded: Changed 1 files. [xx:xx:xx]
> Local : http://localhost:8080/
> Network : http://<IP>:8080/
> HTTPS : Disabled
> Profile : Debug
> Hot Reload : Normal
> Index Template : Default
> URL Rewrite [index_on_404] : False
> Build Time Use : 1190 millis
[INFO] A perfect compilation!
Environment:
I'm working on a Docker Container, offline, with a custom Rust toolchain and a custom registry. I've been working with them for 3 months and have never had a problem so far, so I want to remove these two from the possible error case.
With my toolchain and registry: I have two full Rust apps working. One with an Axum server and Dioxus client, communicating with REST and WebSockets. Another with cryptoki (RSA PKCS#11), without any issue so far.
- Dioxus version:
v0.4.0 - Dioxus cli version:
v0.4.1 - Cryptoki version:
v0.6.1 - Rust version:
1.70.0,stable - OS info:
Docker container:Debian GNU/Linux 11 (bullseye)
Questionnaire
- [x] I'm interested in fixing this myself but don't know where to start
Just out of curiosity what would be the use case? Cryptoki frequently needs PKCS11 driver anyway and you'd have to be able to access the device somehow (eg. via pcsclite).
I'm working on a light web client to interact with an HSM and a database.