drogue-iot / reqwless

Rust async HTTP client for embedded/no_std
Apache License 2.0
129 stars 18 forks source link

Seeing error with a server supportint TLS1.3 #31

Closed eranrund closed 1 year ago

eranrund commented 1 year ago

Hello!

I'm trying to issue a GET request to https://api.mixin.one and seeing the following:

[2023-04-03T20:57:16Z TRACE embedded_tls::asynch] State ClientHello -> ServerHello
[2023-04-03T20:57:16Z TRACE embedded_tls::connection] ********* ServerHello
[2023-04-03T20:57:16Z TRACE embedded_tls::asynch] State ServerHello -> ServerVerify
[2023-04-03T20:57:16Z TRACE embedded_tls::asynch] State ServerVerify -> ServerVerify
[2023-04-03T20:57:16Z TRACE embedded_tls::connection] Verifying certificate!
[2023-04-03T20:57:16Z TRACE embedded_tls::connection] Certificate verified!
[2023-04-03T20:57:16Z TRACE embedded_tls::connection] Verifying signature!
[2023-04-03T20:57:16Z TRACE embedded_tls::connection] Signature verified!
[2023-04-03T20:57:16Z TRACE embedded_tls::connection] ************* Finished
[2023-04-03T20:57:16Z TRACE mio::poll] deregistering event source from poller
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Tls(InvalidSignature)', src/main.rs:140:10

I think that server should be supporting TLS1.3 so I am wondering why this is not working. I'm using the following janky code:

    let url = format!("https://api.mixin.one:443");
    let mut tls_read_buf: [u8; 16384] = [0; 16384];
    let mut tls_write_buf: [u8; 16384] = [0; 16384];
    let mut client = HttpClient::new_with_tls(
        &TokioTcp,
        &StdDns,
        TlsConfig::new(
            OsRng.next_u64(),
            &mut tls_read_buf,
            &mut tls_write_buf,
            TlsVerify::None,
        ),
    ); // Types implementing embedded-nal-async
    let mut rx_buf = [0; 4096];
    let mut req = client
        .request(Method::GET, &url)
        .await
        .unwrap()
        .content_type(ContentType::TextPlain);

    let response = req.send(&mut rx_buf).await.unwrap();

    let b = response.body().unwrap();
    let bb = b.read_to_end().await.unwrap();

    println!("{:?}", std::str::from_utf8(bb));

TokioTcp and StdDns were copy-pasted from the tests code in this repo. This is running on a Mac M1.

Thanks!

lulf commented 1 year ago

I think this is probably related to https://github.com/drogue-iot/embedded-tls/issues/75

bugadani commented 1 year ago

I believe this issue can now be closed.