Master HTTP/HTTPS Debugging on macOS with Charles: A Step‑by‑Step Guide
This tutorial walks you through using Charles on macOS to capture and manipulate HTTP and HTTPS traffic for both PC and mobile devices, covering proxy configuration, SSL handling, breakpoints, throttling, DNS spoofing, request rewriting, remote/local redirection, and basic stress testing.
HTTP and TCP/IP are the foundation of web traffic. This article introduces how to use Charles on macOS to capture HTTP and HTTPS requests for both PC and mobile devices.
1. PC‑side HTTP capture
Open the top menu, select Proxy → macOS Proxy to enable PC‑side capture.
2. PC‑side HTTPS capture
Install the Charles root certificate and trust it via SSL Proxying → Install Charles Root Certificate.
Enable SSL Proxying: Proxy → SSL Proxying Settings, check Enable SSL Proxying , then configure the domain and port as shown.
Click confirm to start capturing both HTTP and HTTPS requests.
3. Mobile capture
Enable Proxy → Poxy Setting, check all options, set the proxy port, then configure the mobile device’s Wi‑Fi HTTP proxy to the PC’s IP address and port (e.g., 8888). The PC’s local IP can be found under Help → Local IP Address.
4. Mobile HTTPS capture
Install and trust the root certificate on the phone, then open
Help → SSL Proxying → Install Charles Root Certificate on a Mobile Device Or Remote Browser. Visit chls.pro/ssl on the phone to download the certificate.
5. Request breakpoints
Enable breakpoints to debug requests. When a request hits a breakpoint, a dialog appears allowing you to modify the request or response before execution.
Identify the request URL to breakpoint.
Open Proxy → Breakpoints Setting (shortcut ⌘+Shift+K), add the URL, choose to modify Request or Response.
Resend the request; the breakpoint dialog lets you edit and then execute.
6. Throttle network speed
Simulate weak network conditions via Proxy → Throttle Settings, where you can set bandwidth limits.
7. Simple stress testing
Select a request, right‑click and choose Repeat Advanced to repeat the request with configurable iteration count and concurrency.
8. DNS spoofing
Redirect a domain to a custom IP via Tool → DNS Spoofing. Example: map www.baidu.com to scny.weiwogroup.cn. Note the limitation that the target port must match.
9. Request rewriting
Similar to breakpoints but persistent. Enable Tool → Rewrite Settings and define rules to modify Path, URL, Body, Query, or Header using regular expressions.
10. Remote request mapping
Use Tool → Map Remote to forward remote endpoints to another remote address, useful for directing production APIs to a local development server.
11. Local request mapping
Similar to remote mapping but forwards the request to a local file, allowing you to capture and edit responses locally.
Additional utilities
Other features include port forwarding via the Proxy and Tool menus, which can be explored further as needed.
Lin is Dream
Sharing Java developer knowledge, practical articles, and continuous insights into computer engineering.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
