ProxymanApp / Proxyman

Modern. Native. Delightful Web Debugging Proxy for macOS, iOS, and Android ⚡️
https://proxyman.io
5.34k stars 177 forks source link

No traffic when using `rustls-tls` #2061

Closed martinmose closed 1 week ago

martinmose commented 1 week ago

Description

First and foremost, thank you for an excellent piece of software! My colleagues and I use Postman extensively in our development workflow for native iOS/Android apps. Recently, we've started integrating Rust alongside Swift/Kotlin, primarily using Rust for handling network tasks. For HTTP client functionality, we rely on the popular reqwest crate.

To avoid dealing with OpenSSL, we've switched to using rustls-tls. Our Cargo.toml configuration looks like this:

reqwest = { version = "0.12.4", features = [
  "json",
  "rustls-tls",
], default-features = false }

However, after this change, we no longer see any traffic in Proxyman. We would greatly appreciate it if this could be supported again. It might be an edge case (apologies for that), but I'm posting this issue to see if there's something obvious we've missed.

Steps to Reproduce

main.rs:

use reqwest::Error;

#[tokio::main]
async fn main() -> Result<(), Error> {
    let response = reqwest::get("https://httpbin.org/get").await?;

    if response.status().is_success() {
        let body = response.text().await?;
        println!("Response Text: {}", body);
    } else {
        println!("Request failed with status: {}", response.status());
    }

    Ok(())
}

Cargo.toml:

[package]
name = "simple_request"
version = "0.1.0"
edition = "2021"

[dependencies]
reqwest = { version = "0.12.5", features = [
  "json",
  "rustls-tls",
], default-features = false }
tokio = { version = "1.38.0", features = ["full"] }

Current Behavior

No traffic appears in Proxyman.

Expected Behavior

When the Cargo.toml is configured like this:

[package]
name = "simple_request"
version = "0.1.0"
edition = "2021"

[dependencies]
reqwest = "0.12.5"
tokio = { version = "1.38.0", features = ["full"] }

We see the request in Proxyman.

Environment

NghiaTranUIT commented 1 week ago

Hi, it's not a bug from Proxyman. It's how the reqwest lib works. By default, the reqwest doesn't use any proxy, so Proxyman can't capture it automatically.

To capture traffic from reqwest

To decrypt HTTPS data


If it's from Ruby, Python or NodeJS, Proxyman has the Auto Setup tool, but not for Rust.

I haven't supported it yet, so we have to manually do it.

martinmose commented 1 week ago

Hi,

I wasn't sure how to classify this "issue", so I chose to label it as a bug. 😅

Thank you very much for the helpful information! We can definitely work around that. I can confirm that it works if I do the following:

use anyhow::Result;
use reqwest::Url;

#[tokio::main]
async fn main() -> Result<()> {
    let proxy_url = Url::parse("http://localhost:9090")?;
    let client = reqwest::Client::builder()
        .danger_accept_invalid_certs(true)
        .proxy(reqwest::Proxy::https(proxy_url)?)
        .build()?;
    let response = client.get("https://httpbin.org/get").send().await?;

    if response.status().is_success() {
        let body = response.text().await?;
        println!("Response Text: {}", body);
    } else {
        println!("Request failed with status: {}", response.status());
    }

    Ok(())
}
NghiaTranUIT commented 1 week ago

Thanks, I will update our Documentation to make Proxyman work with Rust + Reqwest 🙇