quinn-rs / quinn

Async-friendly QUIC implementation in Rust
Apache License 2.0
3.85k stars 394 forks source link

Errors from certificate configuration example in guidebook #1312

Closed jihiggins closed 2 years ago

jihiggins commented 2 years ago

The example at doesn't seem to compile.

Problem one is just an extra parenthesis:

let mut crypto = rustls::ClientConfig::builder()
    .with_safe_defaults()
    .with_single_cert(vec![cert]), key)?  // <---- [cert]) should just be [cert]
    .with_no_client_auth();
let client_config = ClientConfig::new(Arc::new(crypto));

Fixing that leads to the following error:

error[E0599]: no method named `with_single_cert` found for struct `ConfigBuilder<rustls::ClientConfig, WantsVerifier>` in the current scope
  --> networking\src\lib.rs:30:10
   |
30 |         .with_single_cert(vec![cert], key)?
   |          ^^^^^^^^^^^^^^^^ method not found in `ConfigBuilder<rustls::ClientConfig, WantsVerifier>`
   |
   = note: the method was found for
           - `ConfigBuilder<rustls::ClientConfig, WantsTransparencyPolicyOrClientCert>`
           - `ConfigBuilder<rustls::ClientConfig, WantsClientCert>`
           - `ConfigBuilder<rustls::ServerConfig, WantsServerCert>`

Imo, it could also be clearer that this example isn't really following from the LetsEncrypt docs immediately above this section.

djc commented 2 years ago

Thanks for reporting! Would you be up for submitting a PR for this stuff?

FredrikNoren commented 2 years ago

@jihiggins Did you ever find a solution to this? I'm running into the same problem

jihiggins commented 2 years ago

@djc / @FredrikNoren put up a PR, not 100% sure that's the right way to do things, but it's what seemed to fix things for me.