wreq-util provides browser emulation templates for Rust HTTP clients, so your requests match real browser TLS fingerprints. This guide shows how to set up wreq-util and make your HTTP requests indistinguishable from genuine browser traffic.
Cloudflare, Akamai, and DataDome block scrapers by TLS fingerprinting. These anti-bot systems analyze your TLS handshake - the cryptographic negotiation that happens before any actual data is sent - to detect automated traffic.
Most HTTP clients have distinct fingerprints that scream "I'm a bot!" to these detection systems. Traditional solutions like rotating user agents or proxies won't help if your TLS fingerprint gives you away at the network level.
wreq-util is a Rust crate that provides pre-configured browser emulation templates for the wreq HTTP client. Instead of trying to manually configure cipher suites and TLS extensions (a nightmare), you can simply select a browser profile and start making requests that look exactly like Chrome, Firefox, or Safari.
Step 1: Set up your Rust environment
First, you'll need to install the build dependencies for BoringSSL, which wreq uses for TLS operations:
# Ubuntu/Debian
sudo apt-get install build-essential cmake perl pkg-config libclang-dev musl-tools git -y
# macOS
brew install cmake perl pkg-config
# Windows - use Visual Studio with C++ build tools
Now add wreq and wreq-util to your Cargo.toml:
[dependencies]
tokio = { version = "1", features = ["full"] }
wreq = "5"
wreq-util = "2"
Pro tip: Avoid dependencies that useopenssl-sysin the same project. The symbol conflicts withboring-syscan cause segmentation faults. If you need other crypto operations, userustlsinstead.
Step 2: Configure wreq with browser emulation
wreq-util provides over 30 browser profiles out of the box:
use wreq::Client;
use wreq_util::Emulation;
#[tokio::main]
async fn main() -> wreq::Result<()> {
// Pick your browser persona
let client = Client::builder()
.emulation(Emulation::Chrome137) // Latest Chrome
.build()?;
// Test your fingerprint
let resp = client.get("https://tls.peet.ws/api/all")
.send()
.await?;
println!("TLS Fingerprint: {}", resp.text().await?);
Ok(())
}
Available browser profiles include:
- Chrome versions: Chrome100 through Chrome137
- Firefox versions: Firefox109, Firefox128, Firefox133, Firefox135, Firefox136, Firefox139
- Safari versions: Safari15_3 through Safari18_3_1 (including iOS variants)
- Special profiles: FirefoxPrivate136, FirefoxAndroid135, SafariIPad18
Step 3: Make fingerprint-aware requests
Now let's tackle a real-world scenario - scraping a Cloudflare-protected site:
use wreq::{Client, header};
use wreq_util::Emulation;
use std::time::Duration;
#[tokio::main]
async fn main() -> wreq::Result<()> {
let client = Client::builder()
.emulation(Emulation::Chrome136)
.timeout(Duration::from_secs(30))
.danger_accept_invalid_certs(true) // For testing only!
.build()?;
// Add browser-like headers
let resp = client.get("https://protected-site.com")
.header(header::ACCEPT, "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8")
.header(header::ACCEPT_LANGUAGE, "en-US,en;q=0.5")
.header(header::ACCEPT_ENCODING, "gzip, deflate, br")
.header("Sec-Fetch-Dest", "document")
.header("Sec-Fetch-Mode", "navigate")
.header("Sec-Fetch-Site", "none")
.send()
.await?;
if resp.status().is_success() {
println!("Successfully bypassed protection!");
} else {
println!("Status: {}", resp.status());
}
Ok(())
}
The secret sauce: Modern browsers send specific Sec-Fetch-* headers that many bots forget. Including these makes your requests more authentic.
Step 4: Rotate browser profiles for stealth
Static fingerprints are still detectable. Here's how to rotate profiles dynamically:
use wreq::{Client, Response};
use wreq_util::Emulation;
use rand::seq::SliceRandom;
struct StealthClient {
profiles: Vec<Emulation>,
}
impl StealthClient {
fn new() -> Self {
Self {
profiles: vec![
Emulation::Chrome135,
Emulation::Chrome136,
Emulation::Firefox135,
Emulation::Firefox136,
Emulation::Safari18,
],
}
}
async fn get(&self, url: &str) -> wreq::Result<Response> {
let mut rng = rand::thread_rng();
let profile = self.profiles.choose(&mut rng).unwrap();
let client = Client::builder()
.emulation(*profile)
.build()?;
// Match user agent to the TLS profile
let user_agent = match profile {
Emulation::Chrome135 | Emulation::Chrome136 =>
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36",
Emulation::Firefox135 | Emulation::Firefox136 =>
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:136.0) Gecko/20100101 Firefox/136.0",
Emulation::Safari18 =>
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0 Safari/605.1.15",
_ => "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36",
};
client.get(url)
.header(header::USER_AGENT, user_agent)
.send()
.await
}
}
#[tokio::main]
async fn main() -> wreq::Result<()> {
let stealth = StealthClient::new();
// Make requests with random profiles
for i in 0..10 {
let resp = stealth.get("https://httpbin.org/headers").await?;
println!("Request {}: {}", i, resp.status());
tokio::time::sleep(Duration::from_secs(2)).await;
}
Ok(())
}
Step 5: Handle edge cases and troubleshooting
When TLS fingerprinting isn't enough
Some sites use additional detection methods. Here's a nuclear option - combine wreq with a proxy:
use wreq::{Client, Proxy};
use wreq_util::Emulation;
#[tokio::main]
async fn main() -> wreq::Result<()> {
let proxy = Proxy::https("http://proxy-server:8080")?;
let client = Client::builder()
.emulation(Emulation::Chrome136)
.proxy(proxy)
.build()?;
// Your requests now go through the proxy with proper TLS fingerprint
let resp = client.get("https://target-site.com").send().await?;
Ok(())
}
Debugging fingerprint issues
When things go wrong, verify your fingerprint:
async fn check_fingerprint(client: &Client) -> wreq::Result<()> {
// JA3 fingerprint checker
let ja3_resp = client.get("https://ja3er.com/json").send().await?;
println!("JA3 Info: {}", ja3_resp.text().await?);
// TLS details
let tls_resp = client.get("https://www.howsmyssl.com/a/check").send().await?;
let tls_json: serde_json::Value = tls_resp.json().await?;
println!("TLS Version: {}", tls_json["tls_version"]);
println!("Cipher Suites: {}", tls_json["cipher_suites"]);
Ok(())
}
Dealing with specific anti-bot systems
Cloudflare: Focus on HTTP/2 settings and header order
let client = Client::builder()
.emulation(Emulation::Chrome136)
.http2_adaptive_window(true)
.build()?;
Akamai: They check HTTP/2 SETTINGS frame order
// wreq-util handles this automatically with browser emulation
let client = Client::builder()
.emulation(Emulation::Firefox136) // Firefox often works better
.build()?;
DataDome: Requires consistent browser behavior
// Match everything: TLS, headers, and timing
let client = Client::builder()
.emulation(Emulation::Chrome135)
.timeout(Duration::from_secs(30))
.connect_timeout(Duration::from_secs(10))
.build()?;
// Add realistic delays between requests
tokio::time::sleep(Duration::from_millis(rand::thread_rng().gen_range(1000..3000))).await;
PerimeterX: Uses behavioral analysis
// Implement mouse movement simulation via headers
let resp = client.get("https://protected-site.com")
.header("X-PX-AUTHORIZATION", "3") // Varies by site
.header("X-PX-ORIGINAL-TOKEN", generate_px_token())
.send()
.await?;
Common pitfalls and fixes
Cookie persistence across requests:
use wreq::cookie::Jar;
use std::sync::Arc;
let cookie_jar = Arc::new(Jar::default());
let client = Client::builder()
.emulation(Emulation::Chrome136)
.cookie_store(true)
.cookie_provider(cookie_jar.clone())
.build()?;
Certificate pinning bypass: For advanced testing:
let client = Client::builder()
.emulation(Emulation::Firefox136)
.danger_accept_invalid_certs(true)
.use_native_tls(false) // Force BoringSSL
.min_tls_version(tls::Version::TLS_1_2)
.build()?;
WebSocket with browser emulation: Need WebSockets? Here's the right way:
use futures_util::{SinkExt, StreamExt};
use wreq::{Client, Message};
use wreq_util::Emulation;
#[tokio::main]
async fn main() -> wreq::Result<()> {
let client = Client::builder()
.emulation(Emulation::Chrome136)
.build()?;
// Custom headers for WebSocket upgrade
let websocket = client
.websocket("wss://echo.websocket.org")
.header("Origin", "https://example.com")
.header("Sec-WebSocket-Protocol", "chat")
.send()
.await?;
let (mut tx, mut rx) = websocket.into_websocket().await?.split();
// Send messages
tx.send(Message::text("Hello from wreq!")).await?;
// Receive messages
while let Some(msg) = rx.try_next().await? {
if let Message::Text(text) = msg {
println!("Received: {}", text);
}
}
Ok(())
}
Header order matters: Some anti-bots check header ordering. Here's a trick to enforce browser-like order:
use wreq::header::{HeaderMap, HeaderValue};
fn browser_headers() -> HeaderMap {
let mut headers = HeaderMap::new();
// Chrome header order
headers.insert("accept", HeaderValue::from_static("*/*"));
headers.insert("accept-language", HeaderValue::from_static("en-US,en;q=0.9"));
headers.insert("accept-encoding", HeaderValue::from_static("gzip, deflate, br"));
headers
}
HTTP/2 fingerprinting: Some sites check HTTP/2 settings. wreq handles this automatically with browser emulation, but you can fine-tune:
let client = Client::builder()
.emulation(Emulation::Chrome136)
.http2_initial_stream_window_size(6291456) // Chrome's exact value
.http2_initial_connection_window_size(15728640)
.build()?;
Final thoughts
wreq-util reduces TLS fingerprint emulation to picking a browser profile. By mimicking real browser fingerprints at the network level, you can bypass many anti-bot systems that would otherwise block your requests immediately.
Remember: TLS fingerprinting is just one piece of the bot detection puzzle. Combine it with proper header management, request timing, and proxy rotation. Always respect robots.txt and rate limits - being stealthy doesn't mean being unethical.
Bonus: Advanced tricks
Dynamic JA3 modification
Want to generate custom JA3 fingerprints on the fly? Here's a sneaky approach:
use wreq::{Client, tls};
// Custom TLS configuration
let tls_config = tls::Config::builder()
.cipher_list(&[
tls::CipherSuite::TLS13_AES_128_GCM_SHA256,
tls::CipherSuite::TLS13_AES_256_GCM_SHA384,
tls::CipherSuite::TLS13_CHACHA20_POLY1305_SHA256,
])
.enable_sni(true)
.alpn_protocols(&["h2", "http/1.1"])
.build()?;
let client = Client::builder()
.tls_config(tls_config)
.build()?;
Request fingerprint testing
Build your own fingerprint tester to verify your setup:
async fn fingerprint_test() -> wreq::Result<()> {
let endpoints = vec![
("JA3er", "https://ja3er.com/json"),
("TLS.peet", "https://tls.peet.ws/api/all"),
("HowsMySSL", "https://www.howsmyssl.com/a/check"),
];
for (name, url) in endpoints {
let client = Client::builder()
.emulation(Emulation::Chrome136)
.build()?;
let resp = client.get(url).send().await?;
println!("{}: {}", name, resp.text().await?);
}
Ok(())
}
The nuclear option: MITM your own traffic
For ultimate control, proxy through your own MITM:
// First, set up mitmproxy with custom script
// Then route wreq through it
let proxy = Proxy::all("http://localhost:8080")?
.no_proxy(Some("")); // Don't skip any domains
let client = Client::builder()
.emulation(Emulation::Chrome136)
.proxy(proxy)
.danger_accept_invalid_certs(true) // For MITM cert
.build()?;