본문으로 건너뛰기

Rust

Rust reqwest 요청의 프록시와 인증서 처리를 설정해 HTTP/HTTPS 트래픽이 Proxyman에 표시되도록 합니다.

1. 문제​

Rust의 reqwest는 다음 이유로 Proxyman이 HTTP/HTTPS 트래픽을 자동으로 캡처할 수 없습니다:

  • reqwest는 시스템 HTTP 프록시를 따르지 않습니다 -> 트래픽이 Proxyman을 거치지 않습니다
  • reqwest는 자체 서명된 Proxyman 인증서를 신뢰하지 않습니다 -> SSL 오류가 발생합니다

2. 해결 방법​

  • http://localhost:9090의 Proxyman으로 프록시를 직접 설정합니다
  • SSL 검증을 비활성화합니다
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) // trust self-signed certificate
.proxy(reqwest::Proxy::https(proxy_url)?) // Proxy to Proxyman
.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(())
}
정보

시스템 프록시를 무시하는 앱이라면 Network Extension(베타, macOS 26 이상)도 시도해 볼 수 있습니다. 이 기능은 앱마다 프록시를 설정하지 않고도 트래픽을 캡처합니다. HTTPS의 경우 Rust 클라이언트가 여전히 Proxyman 인증서를 신뢰하거나, 위에서 보여준 것처럼 검증을 건너뛰어야 합니다.