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

Wasm support #189

Open
1 task done
Tartopoms opened this issue Nov 15, 2023 · 2 comments
Open
1 task done

Wasm support #189

Tartopoms opened this issue Nov 15, 2023 · 2 comments

Comments

@Tartopoms
Copy link

Tartopoms commented Nov 15, 2023

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-unknown target for rust is installed
    • rustup 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
  • Install the dioxus command line allowing you to compile your rust app to wasm target
    • cargo install dioxus-cli
    • dx --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/unzip the dioxus-template
      • run instead: dx create --template dioxus-template-main
    • If $USER not found -> export USER=any, the value do not matter
# 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

  • I'm interested in fixing this myself but don't know where to start
@wiktor-k
Copy link
Collaborator

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).

@Tartopoms
Copy link
Author

I'm working on a light web client to interact with an HSM and a database.

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

2 participants