|
1 | | -## Installing CA vertificate on android device |
| 1 | +# Installing CA certificate on Android device and emulator |
| 2 | + |
| 3 | + |
| 4 | +## Android emulator (only Android 13 and below) |
| 5 | + |
| 6 | +On the emulator, you can use the below command to install the certificate. You must have `openssl` installed and available on the terminal. |
| 7 | + |
| 8 | +1. Start the emulator with the below command |
| 9 | + ```shell |
| 10 | + emulator -avd <adv_name> -writable-system -wipe-data |
| 11 | + ``` |
| 12 | +2. Run below commands to download and install the certificate |
| 13 | + ```shell |
| 14 | + # This script does not work on Android 14 and real devices |
| 15 | + curl -o $PWD/ca.pem https://raw.githubusercontent.com/AppiumTestDistribution/appium-interceptor-plugin/master/certificate/certs/ca.pem |
| 16 | + file=$PWD/ca.pem |
| 17 | + filename=$(openssl x509 -noout -subject_hash_old -in $file) |
| 18 | + openssl x509 -in $file > $filename.0 |
| 19 | + openssl x509 -in $file -text -fingerprint -noout >> $filename.0 |
| 20 | + adb root |
| 21 | + adb remount |
| 22 | + adb reboot |
| 23 | + adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;' |
| 24 | + adb root |
| 25 | + adb remount |
| 26 | + adb push $filename.0 /system/etc/security/cacerts |
| 27 | + adb remount |
| 28 | + ``` |
| 29 | + |
| 30 | +3. Open `Settings` > `Security settings`> `Encryption and Credentials` > `Encryption and Credentials`. |
| 31 | + |
| 32 | +4. Ensure the installed certificate is displayed under the `System` section of the `Trusted Credentials` settings. |
| 33 | + |
| 34 | + <img width="930" alt="image" src="https://github.com/AppiumTestDistribution/appium-interceptor-plugin/assets/6311526/51885560-be30-455e-9b42-2a829a8f5b8a"> |
| 35 | + |
| 36 | +**NOTE:** If you save the emulator snapshot you don't need to add `-writable-system -wipe-data` when you start the emulator from the snapshot. `-writable-system -wipe-data` is required only once. |
| 37 | + |
| 38 | +
|
| 39 | + |
| 40 | +## Android real device and Android 14 emulator |
2 | 41 |
|
3 | 42 | 1. Download the `ca.pem` file from [here](../certificate/certs/ca.pem) and save it to the computer. |
4 | 43 |
|
|
8 | 47 | adb push downloaded_cert_path/ca.pem /storage/emulated/0/Download |
9 | 48 | ``` |
10 | 49 |
|
11 | | - The above command will push the certificate to download directory of the android device. |
| 50 | + The above command will push the certificate to the download directory of the Android device. |
12 | 51 |
|
13 | 52 | 3. Open `Settings` > `Security settings` > `Encryption and Credentials` > `Install a certificate` > `CA Certificate` > `Install anyway` and choose the `ca.pem` file and install the certificate. |
14 | 53 |
|
15 | | -4. Make sure the installed certificate is displayed under `User` section of `Trusted Credentials` settings. |
| 54 | +4. Ensure the installed certificate is displayed under the `User` section of the `Trusted Credentials` settings. |
16 | 55 |
|
17 | 56 | <img src="./ca_install_steps.gif"> |
18 | 57 |
|
| 58 | + |
| 59 | + |
| 60 | + |
| 61 | +## Verify certificates have been successfully installed |
| 62 | +
|
19 | 63 | 5. Install the plugin by running the command |
20 | 64 |
|
21 | 65 | ```shell |
22 | 66 | appium plugin install --source=npm appium-interceptor |
23 | 67 | ``` |
24 | | -6. To Make sure your setup is working connect your android device/emulator to your machine and run the below command |
| 68 | +6. To Make sure your setup is working connect your Android device/emulator to your machine and run the below command |
25 | 69 | |
26 | 70 | ```shell |
27 | 71 | appium plugin run appium-interceptor test-connection |
28 | 72 | ``` |
29 | 73 |
|
30 | | - A new browser session will be started in the mobile and you should see the below page opened |
| 74 | + A new browser session will be started on the mobile and you should see the below page opened |
31 | 75 | |
32 | 76 | <img src="./test-connection.gif"> |
33 | 77 |
|
34 | | -If you see any errors then retry from step 1 or you can raise an issue with the screeshot and we will guide you with the next steps. |
| 78 | +If you see any errors then please first retry the steps. If it doesn't work please raise an issue with the screenshot and logs and we will investigate it. |
0 commit comments