tauri-apps / tauri

Build smaller, faster, and more secure desktop and mobile applications with a web frontend.
https://tauri.app
Apache License 2.0
85.93k stars 2.6k forks source link

[bug][android] https request failed with handshakefailure #6770

Open Meteplus opened 1 year ago

Meteplus commented 1 year ago

Describe the bug

I used tauri::api::http::ClientBuilder and HttpRequestBuilder::new("POST", "https://...") to make a https request ,but i got this:

04-22 11:36:05.537 31981 32013 I RustStdoutStderr: thread 'tokio-runtime-worker' panicked at 'called Result::unwrap() on an Err value: Network(reqwest::Error { kind: Request, url: Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("www.zhibei.biz")), port: None, path: "/tauri/marqo.jsp", query: None, fragment: None }, source: hyper::Error(Connect, Custom { kind: Other, error: Custom { kind: InvalidData, error: AlertReceived(HandshakeFailure) } }) })', src\lib.rs:24:13 04-22 11:36:05.538 31981 32013 I RustStdoutStderr: note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

BUT,after changed the URL to http://... everything is ok!!!!!

Reproduction

No response

Expected behavior

No response

Platform and versions

tauri_2.0_alpha.08 
android

Stack trace

04-22 11:36:05.537 31981 32013 I RustStdoutStderr: thread 'tokio-runtime-worker' panicked at 'called `Result::unwrap()` on an `Err` value: Network(reqwest::Error { kind: Request, url: Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("www.zhibei.biz")), port: None, path: "/tauri/marqo.jsp", query: None, fragment: None }, source: hyper::Error(Connect, Custom { kind: Other, error: Custom { kind: InvalidData, error: AlertReceived(HandshakeFailure) } }) })', src\lib.rs:24:13
04-22 11:36:05.538 31981 32013 I RustStdoutStderr: note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Additional context

No response

Meteplus commented 1 year ago

is this the same reason causes such an error? https://github.com/seanmonstar/reqwest/issues/923#issuecomment-633986139

Meteplus commented 1 year ago

Now I am sure it IS the SSL configuration on the server side causes this error, because I took a try to post to https://www.google.com the request done we'll and got namal responses

Meteplus commented 1 year ago

Does tauri2.0 uses rustls for ssl? And the rustls does'nt support the weak or insecure ciphers such as TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 and so on,this caused same problems mentioned here: https://github.com/SeerLabs/CiteSeerX/issues/80#issuecomment-830789613

Ballpin commented 5 months ago

For my part it was something with rust being stricter with the ssl certificate and the default cipher did not make the cut. I had to do this.

// cargo.toml reqwest = { version = "0.12.4", default-features = false, features = ["json", "rustls-tls", "blocking"] }

// lib.rs

let client = reqwest::Client::builder().use_rustls_tls().build().unwrap();
let response = client.post("url").send().await?
let result: serde_json::Value = response.json().await?;

Note: Im new to rust and java so i don't know much about it. I just found it out by reading lots and lots of stuff.

Got also help from https://stackoverflow.com/questions/77825270/rust-reqwest-with-certificate-and-key-fails-to-be-authorised