Skip to content

Instantly share code, notes, and snippets.

@vdurante
Created October 1, 2019 18:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vdurante/36b4b6ec2dca0b080d844befc5494996 to your computer and use it in GitHub Desktop.
Save vdurante/36b4b6ec2dca0b080d844befc5494996 to your computer and use it in GitHub Desktop.
How to trust a System Certificate on rooted Android 8+

Pre-Requisites

  • Windows - download cmder. I find it easier to use OpenSSL and nix comands through cmder without having to install anything. Just download, extract the zip, and run cmder.exe
  • Android - it must be rooted
  • Android - you need a file manager with root capabilities. I like using Amaze

How-To

I haven't tested if all these steps are required. I strongly suggest you follow them to generate a valid certificate file using the same structure as Android's.

1. Navigate to SWEX's cert folder

When you click Get Cert on SWEX, it will export and display the certificate file path on the Logs. Copy the full directory path. It should look something like: C:\Users\<username>\Desktop\Summoners War Exporter Files\cert

Now, open cmder and write the following command on the prompt, substituting [swex-cert-folder] with the folder you copied above:

$ cd /d [swex-cert-folder]

2. Generate certificate file

Google names its certificate files using an old hasing algorithm. To get this code, you must run the following command:

$ openssl x509 -inform PEM -subject_hash_old -in ca.pem | head -1
2a07129b

The output of above command is a 8 character alphanumeric code, which will be the name of your cert file. Run the code bellow, substituting [cert-hash-code] with the code you got executing the command above:

$ openssl x509 -inform PEM -text -in ca.pem >> [cert-hash-code].0

Android's file name structure is [cert-hash-code].0. After you ran the code above, you should get a file named something like 2a07129b.0

Now, to follow the exact same structure as Android's file, we need to reorder our file contents. I haven't tested if it works without reordering, but I wanted to make sure everything was exactly the same as Android's.

Open the file in a decent text editor. I suggest Notepad++, since Window's Notepad is quite confusing on line-breaks.

At the bottom of the file, you will see a block of text, which is your certificate:

(...)
-----BEGIN CERTIFICATE-----
<some huge random text>
-----END CERTIFICATE-----

Cut the text above and insert it on the beggining of the file. You should end up with something like this:

-----BEGIN CERTIFICATE-----
<some huge random text>
-----END CERTIFICATE-----
Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number:
(...)

Save the file.

3. Move the file to your phone

This is very straightforward. Just connect your phone to your computer and copy the file into it.

4. Copy the file to the target folder

In Amaze, you will have to enable Root Explorer in the settings. This is common in several File Managers. To access system files, you need to go to the menu and click Root to access the root folder.

Go to the folder you copied your certificate into. Copy the file from there.

Now go to /system/etc/security/cacerts/ and paste it in there. In Amaze, to paste a file you need to click the cliboard icon that appears on the top bar.

5. Set desired permissions

Now, you must find the certificate you just copied into the folder. Click the three dots on the file and go to Properties. Right now you can see that MD5 and SHA-256 hashes can't be displayed due to an error. This is caused due to permission issues.

Scroll down and there is a button called Permissions. Click on it and scroll down once more. Make sure the permissions are set as follows:

Read Write Execute
Owner [x] [x] [ ]
Group [x] [ ] [ ]
Other [x] [ ] [ ]

Now click Set and then Ok.

If everything is correct, you can reopen the file's Properties. You should now be able to see MD5 and SHA-256 hashes properly calculated.

6. Disable root and ejoy!

Now you can enjoy SWEX working on your Android.

If you want to play Summoners War, don't forget to disable Root or use Magisk to hide root status from Summoners War. Com2us is blocking rooted devices from playing Summoners War.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment