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

actix-web doesn't compile with rustls 0.23.1 #3309

Open
victor-chan-dev opened this issue Mar 11, 2024 · 3 comments
Open

actix-web doesn't compile with rustls 0.23.1 #3309

victor-chan-dev opened this issue Mar 11, 2024 · 3 comments

Comments

@victor-chan-dev
Copy link

Expected Behavior

Update the dependencies for actix-web-4.5.1 to use rustls-0.23.1 and have it compile successfully

Current Behavior

After updating the dependencies for actix-web-4.5.1 to use rustls-0.23.1, it fails with the following error:

error[E0282]: type annotations needed
   --> /Users/myself/.cargo/registry/src/index.crates.io-6f17d22bba15001f/actix-web-4.5.1/src/app_service.rs:267:17
    |
267 |                 Ok((path, guards, service))
    |                 ^^ cannot infer type of the type parameter `E` declared on the enum `Result`
    |
help: consider specifying the generic arguments
    |
267 |                 Ok::<(ResourceDef, Vec<Box<dyn Guard>>, Box<dyn actix_service::Service<ServiceRequest, Error = error::error::Error, Future = std::pin::Pin<Box<(dyn futures_core::Future<Output = std::result::Result<ServiceResponse, error::error::Error>> + 'static)>>, Response = ServiceResponse>>), E>((path, guards, service))
    |                   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

error[E0283]: type annotations needed
   --> /Users/myself/.cargo/registry/src/index.crates.io-6f17d22bba15001f/actix-web-4.5.1/src/app_service.rs:267:17
    |
266 |                 let service = factory_fut.await?;
    |                                                - type must be known at this point
267 |                 Ok((path, guards, service))
    |                 ^^ cannot infer type of the type parameter `E` declared on the enum `Result`
    |
    = note: multiple `impl`s satisfying `_: From<()>` found in the following crates: `aws_lc_rs`, `serde_json`:
            - impl From<()> for Value;
            - impl From<()> for aws_lc_rs::error::KeyRejected;
            - impl From<()> for aws_lc_rs::error::Unspecified;
    = note: required for `Result<(ResourceDef, Vec<Box<dyn Guard>>, Box<dyn Service<ServiceRequest, Error = Error, Future = Pin<Box<dyn Future<Output = Result<ServiceResponse, ...>>>>, Response = ...>>), ...>` to implement `FromResidual<std::result::Result<std::convert::Infallible, ()>>`
    = note: the full type name has been written to '/Users/myself/git-workplace/actix-tls-example/target/debug/deps/actix_web-7962e616c7d035ff.long-type-2618429493372448216.txt'
help: consider specifying the generic arguments
    |
267 |                 Ok::<(ResourceDef, Vec<Box<dyn Guard>>, Box<dyn actix_service::Service<ServiceRequest, Error = error::error::Error, Future = std::pin::Pin<Box<(dyn futures_core::Future<Output = std::result::Result<ServiceResponse, error::error::Error>> + 'static)>>, Response = ServiceResponse>>), E>((path, guards, service))
    |                   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

error[E0283]: type annotations needed
   --> /Users/myself/.cargo/registry/src/index.crates.io-6f17d22bba15001f/actix-web-4.5.1/src/app_service.rs:267:17
    |
267 |                 Ok((path, guards, service))
    |                 ^^ cannot infer type of the type parameter `E` declared on the enum `Result`
...
281 |                 .collect::<Result<Vec<_>, _>>()?
    |                                                - type must be known at this point
    |
    = note: multiple `impl`s satisfying `(): From<_>` found in the following crates: `aws_lc_rs`, `core`:
            - impl From<aws_lc_rs::error::Unspecified> for ();
            - impl<T> From<!> for T;
            - impl<T> From<T> for T;
    = note: required for `std::result::Result<AppRouting, ()>` to implement `FromResidual<std::result::Result<std::convert::Infallible, _>>`
help: consider specifying the generic arguments
    |
267 |                 Ok::<(ResourceDef, Vec<Box<dyn Guard>>, Box<dyn actix_service::Service<ServiceRequest, Error = error::error::Error, Future = std::pin::Pin<Box<(dyn futures_core::Future<Output = std::result::Result<ServiceResponse, error::error::Error>> + 'static)>>, Response = ServiceResponse>>), E>((path, guards, service))
    |                   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

error[E0283]: type annotations needed
   --> /Users/myself/.cargo/registry/src/index.crates.io-6f17d22bba15001f/actix-web-4.5.1/src/scope.rs:474:17
    |
473 |                 let service = factory_fut.await?;
    |                                                - type must be known at this point
474 |                 Ok((path, guards, service))
    |                 ^^ cannot infer type of the type parameter `E` declared on the enum `Result`
    |
    = note: multiple `impl`s satisfying `_: From<()>` found in the following crates: `aws_lc_rs`, `serde_json`:
            - impl From<()> for Value;
            - impl From<()> for aws_lc_rs::error::KeyRejected;
            - impl From<()> for aws_lc_rs::error::Unspecified;
    = note: required for `Result<(ResourceDef, Vec<Box<dyn Guard>>, Box<dyn Service<ServiceRequest, Error = Error, Future = Pin<Box<dyn Future<Output = Result<ServiceResponse, ...>>>>, Response = ...>>), ...>` to implement `FromResidual<std::result::Result<std::convert::Infallible, ()>>`
    = note: the full type name has been written to '/Users/myself/git-workplace/actix-tls-example/target/debug/deps/actix_web-7962e616c7d035ff.long-type-5950418878366739901.txt'
help: consider specifying the generic arguments
    |
474 |                 Ok::<(ResourceDef, Vec<Box<dyn Guard>>, Box<dyn actix_service::Service<ServiceRequest, Error = error::error::Error, Future = std::pin::Pin<Box<(dyn futures_core::Future<Output = std::result::Result<ServiceResponse, error::error::Error>> + 'static)>>, Response = ServiceResponse>>), E>((path, guards, service))
    |                   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

error[E0283]: type annotations needed
   --> /Users/myself/.cargo/registry/src/index.crates.io-6f17d22bba15001f/actix-web-4.5.1/src/scope.rs:474:17
    |
474 |                 Ok((path, guards, service))
    |                 ^^ cannot infer type of the type parameter `E` declared on the enum `Result`
...
485 |                 .collect::<Result<Vec<_>, _>>()?
    |                                                - type must be known at this point
    |
    = note: multiple `impl`s satisfying `(): From<_>` found in the following crates: `aws_lc_rs`, `core`:
            - impl From<aws_lc_rs::error::Unspecified> for ();
            - impl<T> From<!> for T;
            - impl<T> From<T> for T;
    = note: required for `std::result::Result<ScopeService, ()>` to implement `FromResidual<std::result::Result<std::convert::Infallible, _>>`
help: consider specifying the generic arguments
    |
474 |                 Ok::<(ResourceDef, Vec<Box<dyn Guard>>, Box<dyn actix_service::Service<ServiceRequest, Error = error::error::Error, Future = std::pin::Pin<Box<(dyn futures_core::Future<Output = std::result::Result<ServiceResponse, error::error::Error>> + 'static)>>, Response = ServiceResponse>>), E>((path, guards, service))
    |                   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

error[E0282]: type annotations needed
   --> /Users/myself/.cargo/registry/src/index.crates.io-6f17d22bba15001f/actix-web-4.5.1/src/scope.rs:474:17
    |
474 |                 Ok((path, guards, service))
    |                 ^^ cannot infer type of the type parameter `E` declared on the enum `Result`
    |
help: consider specifying the generic arguments
    |
474 |                 Ok::<(ResourceDef, Vec<Box<dyn Guard>>, Box<dyn actix_service::Service<ServiceRequest, Error = error::error::Error, Future = std::pin::Pin<Box<(dyn futures_core::Future<Output = std::result::Result<ServiceResponse, error::error::Error>> + 'static)>>, Response = ServiceResponse>>), E>((path, guards, service))
    |                   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Some errors have detailed explanations: E0282, E0283.
For more information about an error, try `rustc --explain E0282`.

Possible Solution

When rustls moved to 0.23.0, it introduced a dependency on aws-lc-rs which is its new default cryptography provider.

However, there seems to be some compiler confusion where rust can't tell whether or not the tuple Ok((path, guards, service)) in both the app_service.rs & scope.rs is casted to a struct from the serder_json crate or the aws-lc-rs crate.

My rust is very entry-level, but I'm hoping the fix can be as straightforward as adding an explicit cast to allow the compile to work as expected

Steps to Reproduce (for bugs)

  1. Go to the rustls dependency in actix-web's Cargo.toml file
  2. Update dependency from 0.22 to 0.23.1
  3. Run cargo test
  4. See exception

Context

I'm trying to set-up an HTTPS server that is FIPS compliant. I was hoping to use the bind_rusttls_022 function to use the latest rustls version, which is FIPS certified via the aws-lc-rs library

Your Environment

  • Rust Version (I.e, output of rustc -V): rustc 1.76.0 (07dca489a 2024-02-04)
  • Actix Web Version:v 4.5.1
@asonix
Copy link

asonix commented Mar 11, 2024

bind_rustls_022 only works with rustls 0.22

Mixing and matching multiple versions of the same library generally isn't supported

When rustls 0.23 support is added, it will likely be through a new feature and bind call like bind_rustls_023

@DokkanWiki
Copy link

This error seems to also happen with rustls 0.22 with the aws-lc-rs feature enabled.

@robjtede
Copy link
Member

Yea the rustls story is getting more complicated with the additional backends they're adding; not quite sure how to support them nicely yet.

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

4 participants