Skip to content

Instantly share code, notes, and snippets.

@Apihplays
Forked from vdurante/readme.md
Last active August 10, 2023 13:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Apihplays/52a26b41a6186e3e4f84074698949ebd to your computer and use it in GitHub Desktop.
Save Apihplays/52a26b41a6186e3e4f84074698949ebd to your computer and use it in GitHub Desktop.
How to trust a System Certificate on rooted Android 11+ using Magisk module

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
  • Magisk module - Since android 7 up to android 11+ , system can not be R/W by any mean anymore unless you flash and forget this module to make thing easier. Go grab this Magisk OverlayFS

How-To

I have tested all these step. I strongly suggest you follow them accordingly. Phone that being used was Redmi Note 10 (Mojito) Miui14.0.3 Global Official

1. Navigate to Summoners War Exporter (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

Run the following command:

$ openssl x509 -inform PEM -subject_hash_old -in ca.pem
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.

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. Flash Magisk module

Once you are done download this module, flash this module in Magisk app and reboot.

4. Move the file to your phone

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

5. 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.

6. 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's Zygisk feature and Enforce DenyList 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