Skip to content

Commit 94fcd5e

Browse files
authored
Update certificate-installation.md (#17)
Add script and instructions for installing the CA certificate on the emulator
1 parent c806e1a commit 94fcd5e

File tree

1 file changed

+50
-6
lines changed

1 file changed

+50
-6
lines changed

docs/certificate-installation.md

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,43 @@
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
241
342
1. Download the `ca.pem` file from [here](../certificate/certs/ca.pem) and save it to the computer.
443
@@ -8,27 +47,32 @@
847
adb push downloaded_cert_path/ca.pem /storage/emulated/0/Download
948
```
1049
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.
1251
1352
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.
1453
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.
1655
1756
<img src="./ca_install_steps.gif">
1857
58+
59+
60+
61+
## Verify certificates have been successfully installed
62+
1963
5. Install the plugin by running the command
2064
2165
```shell
2266
appium plugin install --source=npm appium-interceptor
2367
```
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
2569
2670
```shell
2771
appium plugin run appium-interceptor test-connection
2872
```
2973
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
3175
3276
<img src="./test-connection.gif">
3377
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

Comments
 (0)