Keats / jsonwebtoken

JWT lib in rust
MIT License
1.62k stars 252 forks source link

error[E0599]: no method named `description_` found for struct `KeyRejected` in the current scope #323

Closed Richard-Rogalski closed 11 months ago

Richard-Rogalski commented 11 months ago

CPU: ppc64le (power8) Rust: rustc 1.71.0-nightly (8ede3aae2 2023-07-12) (gentoo) and also rustc 1.71.0 (8ede3aae2 2023-07-12) (gentoo) Version: jsonwebtoken = "8.3.0"

I think this problem is because of either ppc64le, or (more likely) ring. Upstream ring does not have support on PPC, but IBM has a fork that does, https://github.com/IBM/ring/ . The error is:

error[E0599]: no method named `description_` found for struct `KeyRejected` in the current scope
  --> /var/tmp/portage/net-im/conduit-9999/work/cargo_home/gentoo/jsonwebtoken/src/crypto/rsa.rs:42:49
   |
42 |         .map_err(|e| ErrorKind::InvalidRsaKey(e.description_()))?;
   |                                                 ^^^^^^^^^^^^ method not found in `KeyRejected`

For more information about this error, try `rustc --explain E0599`.
error: could not compile `jsonwebtoken` (lib) due to previous error

Caused by:
  process didn't exit successfully: `rustc --crate-name jsonwebtoken --edition=2021 /var/tmp/portage/net-im/conduit-9999/work/cargo_home/gentoo/jsonwebtoken/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C linker-plugin-lto -C codegen-units=32 --cfg 'feature="default"' --cfg 'feature="pem"' --cfg 'feature="simple_asn1"' --cfg 'feature="use_pem"' -C metadata=48a81f1bd416dd9f -C extra-filename=-48a81f1bd416dd9f --out-dir /var/tmp/portage/net-im/conduit-9999/work/conduit-9999/target/release/deps -L dependency=/var/tmp/portage/net-im/conduit-9999/work/conduit-9999/target/release/deps --extern base64=/var/tmp/portage/net-im/conduit-9999/work/conduit-9999/target/release/deps/libbase64-e05657e6542dfd9f.rmeta --extern pem=/var/tmp/portage/net-im/conduit-9999/work/conduit-9999/target/release/deps/libpem-1f44a576910ccc45.rmeta --extern ring=/var/tmp/portage/net-im/conduit-9999/work/conduit-9999/target/release/deps/libring-d49a705281785793.rmeta --extern serde=/var/tmp/portage/net-im/conduit-9999/work/conduit-9999/target/release/deps/libserde-99876933d86d440f.rmeta --extern serde_json=/var/tmp/portage/net-im/conduit-9999/work/conduit-9999/target/release/deps/libserde_json-92c2cc54494772bc.rmeta --extern simple_asn1=/var/tmp/portage/net-im/conduit-9999/work/conduit-9999/target/release/deps/libsimple_asn1-ba92fdae2f5fe6a0.rmeta --cap-lints allow -C target-cpu=pwr8 -C opt-level=3 -C strip=symbols -L native=/var/tmp/portage/net-im/conduit-9999/work/conduit-9999/target/release/build/ring-a13e0b7e1f166cbf/out` (exit status: 1)

Full build log will be attached below.

I don't know much about rust or where the issue really lies.... but I would be willing to (try) making a PR to make ring optional in favor of the system openssl (openssl-sys), if that would be alright :) ( if that is alright, can I also get an estimate on how hard that would be :b )

build.log

robfreed commented 11 months ago

Welp, unsure if this helps, but it builds if e.description_()) is replaced by ErrorKind::RsaFailedSigning.

Note that this isn't a proper fix

We'll have to wait for a proper fix. I wonder what changed prior the introduction of e.description_()).

robfreed commented 11 months ago

Looks like e.description_() was added in 30571cafd2949f3d769a1658695ef5c9e9c4f8e4. Reverting it should probably make it work. Unsure of the impact if this commit was reverted.

robfreed commented 11 months ago

fyi: Richard and I both have ppc64le (power8) systems

Keats commented 11 months ago

It seems present in the fork? https://github.com/IBM/ring/blob/master/src/error.rs#L153 but not in the ppc branch: https://github.com/IBM/ring/blob/ppc-0.16.20/src/error.rs#L134

robfreed commented 11 months ago

Hmm, thanks for pointing that out. I didn't look to see if it was present in the ppc branch. I locally added it in the ppc branch and it now builds fine. (We are building conduit)

(I did a quick "fix", so it's not a proper fix, but it works. I'll have to check that out then)

I only added this part

    /// The value returned from <Self as std::error::Error>::description()
    pub fn description_(&self) -> &'static str {
        self.0
    }

builds fine, but it's missing most of https://github.com/Keats/jsonwebtoken/commit/30571cafd2949f3d769a1658695ef5c9e9c4f8e4.

Thanks for pointing that out!

LIBCLANG_PATH="/usr/lib/llvm/15/lib64/" cargo build --release
   [...]
   Compiling jsonwebtoken v8.3.0
   [...]
    Finished release [optimized] target(s) in 6m 29s

@Richard-Rogalski you can temporarily do this

Richard-Rogalski commented 11 months ago

ugh, I'll make a PR to IBM/ring I guess.. thanks y'all <3

erichte-ibm commented 10 months ago

Hi, I just pushed a revised version of ppc-0.16.20 to IBM/ring that is actually based on 0.16. The original version included some commits intended for a future version that should not have been there, hopefully this should address the issue. As it was a git history rewrite, you may need to force a clean rebuild to make sure it fetches the new version. Please let me know if you encounter any issues.

robfreed commented 10 months ago

Thank you so much! Just in time for my birthday!