Feature Suggestion: Installing proxy certificate on Android emulators
See original GitHub issueThe problem
** Feature suggestion/request ** This would be the counterpart of https://github.com/appium/appium-xcuitest-driver/blob/master/lib/commands/certificate.js for android to provide the ability to install proxy certificates on android emulators.
Details
Here’s how to install proxy certificates with adb and ruby.
`emulator -avd <avd-name> -http-proxy <proxy-address>:<proxy-port> -writable-system &` # '-writable-system' gives root access
# make sure proxy server is running on specified port before starting emulator if you want to set proxy server for emulator
cert_file = '~/.mitmproxy/mitmproxy-ca-cert.cer' # i used mitm, though any valid .cer file should work.
filename =`openssl x509 -in #{cert_file} -hash -noout`.chomp # creating filename for .0 file
`sh "openssl x509 -in #{cert_file} > #{filename}.0"`# dumping content of the .cer file, .0 is the binary file which stores the system certificates
`sh "openssl x509 -in #{cert_file} -text -fingerprint -noout >> #{filename}.0"`
`sh 'adb root'`
`sh 'adb remount'`
`sh "adb push #{filename}.0 /system/etc/security/cacerts"`
`sh 'adb remount'`
`sh "rm #{filename}.0"`
After doing these steps if emulator are not reset to original config, the system certificate file will persist. No more annoying SSL errors as long as the certificate signatue does not changes.
I used MITM proxy hence providing proxy server and port was required.
Pro-
- No need to set a password for installing a certificate.
- The whole process hardly takes 10 seconds, including device boot.
- Once the process is done
-writable-system
can be removed, simply reboot without the flag. - This could also work with real rooted device if anyone utilizes rooted device in there automation infra.
Cons-
- We are making changes to Android system, very minimal though at lease for emulators.
Why not a PR?
I don’t have enough knowledge/experiance with node.js and Appium codebase. So my pull request will be stuck forever into review or possibly rejected. I’m raising it here so someone can pick this up and implement it as soon they can.
Environment
- Appium version (or git revision) that exhibits the issue: NA
- Last Appium version that did not exhibit the issue (if applicable): NA
- Desktop OS/version used to run Appium: NA
- Node.js version (unless using Appium.app|exe): NA
- Mobile platform/version under test: Android
- Real device or emulator/simulator: emulator( if the real device is rooted it should work, never tested though)
- Appium CLI or Appium.app|exe: NA
cc: @mykola-mokhnach
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:44
Top GitHub Comments
-writable-system
argument is also redundantAbout checking the current proxy value set by
-http-proxy
, I havn’t done that as I never needed it. I think it might be possible, I’ll try to find out if there is anyway to do it.I’ll test appium/appium-android-driver#386 this weekend and update here.