Automating mitmproxy and Improving Hulu’s Build Loading Tool for Roku
--
By Chandler Underwood, Software Developer
Web-connected applications such as Hulu’s have complex and constant network traffic to a variety of services. A proxy is a tool that sits between a web client and the internet and allows requests to be observed, rerouted, and changed. This is valuable for understanding the network call patterns of an app, as well as changing network requests to satisfy testing requirements.
Because Roku devices do not have a native proxy solution, we needed to configure our app to use mitmproxy, an open-source HTTPS proxy. We then automated this setup for mitmproxy and added it to our open source Roku build loading tool roku-dev-cli. Developers were already using roku-dev-cli to deploy builds and monitor logs, so this extra proxy functionality is convenient for them to use. This benefits Roku developers because:
- The developer doesn’t have to manually copy files and modify their app code every time they want to use a proxy.
- Allows the modification of responses from any service to trigger complex test scenarios.
- Allows the developer to mock APIs that don’t even exist yet and remove dependencies on other teams
Removing some of the barriers to thorough testing such as these allow our developers and QA engineers to focus on quality and deliver better features sooner.
Finding a Proxy
There are very few documented processes for using an HTTPS proxy with Roku apps, so finding one to work was a process of trial and error. Charles Proxy is a tool used by other teams at Hulu so it was the first attempted solution. Charles Proxy failed to decrypt traffic, a problem that other Roku developers had also encountered. An inconspicuous error was being thrown about an unexpected header for all network calls. Finding this error insurmountable, a different solution was required.
Next, we evaluated mitmproxy, an open source command-line driven HTTPS proxy. mitmproxy has a wide range of features, including a web GUI interface to inspect traffic, a dump to create logs of traffic history, and a Python API to write add-ons in the form of automated scripts to modify and redirect requests or responses. One challenge we saw while integrating mitmproxy was certain network calls from the Roku OS or the native video player could not have their HTTPS certificate overridden. This…