ECHW - Encrypted Client Hello Wrapper
A Rust library for making HTTP GET and POST requests with Encrypted Client Hello (ECH) support using rustls and hickory-dns.
Features
Quick Start
Add to your Cargo.toml:
[]
= "0.1.0"
= { = "1.0", = ["full"] }
= "0.11"
Basic GET Request
use EchClient;
use Error;
async
POST Request with JSON
use EchClient;
use Error;
async
API Reference
EchClient
The main client for making ECH-enabled HTTP requests.
Builder Methods
EchClient::builder(outer_hostname, inner_hostname)- Create a new client builder.port(port)- Set the port (default: 443).cloudflare_dns()- Use Cloudflare DNS for ECH config lookup (default: Google DNS).grease()- Use GREASE ECH for testing.ech_config_file(path)- Load ECH config from file.ca_file(path)- Use custom CA certificate file
Request Methods
client.get(path)- Make a GET requestclient.post(path, body)- Make a POST requestclient.post_with_headers(path, body, headers)- Make a POST request with custom headers
EchResponse
Response object containing:
status: String- HTTP status lineheaders: Vec<String>- Response headersbody: Vec<u8>- Response body as bytesech_status: EchStatus- ECH negotiation statusbody_as_string()- Convert body to UTF-8 string
EchStatus
ECH negotiation status:
EchStatus::Accepted- ECH was successfully negotiatedEchStatus::Grease- GREASE ECH extension was usedEchStatus::NotOffered- ECH was not offered
Examples
Run the included examples:
# Simple GET request
# JSON POST request
ECH (Encrypted Client Hello)
ECH is a TLS extension that encrypts the Server Name Indication (SNI) and other identifying parts of the TLS Client Hello message. This prevents network observers from seeing which specific server within a host the client is trying to reach.
How it works
- The client looks up ECH configuration for the target domain using DNS-over-HTTPS (using hickory-dns).
- The client connects to the "outer" server but encrypts the real "inner" server name using ECH (using rustls).
- The outer server forwards the connection to the inner server after decrypting the ECH extension
- The TLS handshake completes with the inner server while protecting the SNI from network observation
Testing
The library includes support for ECH GREASE extensions for testing environments where real ECH configs are not available.
License
MIT License - see LICENSE file for details.