Closed chasevis closed 8 months ago
This probably means that WSA hasn't implemented Android's VPN APIs. That's annoying but not especially surprising (implementing an Android-only VPN subsystem within Windows sounds hard and not widely relevant, better to just skip it).
That is awkward, and it will break HTTP Toolkit's automatic interception, but you should still be able to intercept WSA by manually configuring it instead. You'll need to configure the proxy settings there and make it trust HTTP Toolkit's certificate. The settings you'll need are available in the 'Anything' interception option in HTTP Toolkit.
I've never actually tried WSA myself, so I don't know how to do that, but I'm sure there will be options somewhere. If you make any progress, or you hit any clear problems, can you share an update here? I'd be happy to help investigate further, or to write up the steps in the docs for others if you get this working.
@pimterry would doing this lead to full trust and functionality of httptoolkit being able to see everything (that isnt pinned)?
HTTP Toolkit Full System Trust WSA Steps designed for Windows
Involves rooting WSA then installing a system certificate manually. You can skip steps you've already done in regards to rooting.
Note: You may not need to actually root WSA (I haven't tested it without root) but I reckon it's a good thing to have and it's not that hard.
You will need:
You should add adb.exe and openssl.exe to your path to make this way easier. Otherwise, you'll need to use the full form of the path when executing it in folders.
Add-AppxPackage -Register C:\WSA\{msix-folder}\AppxManifest.xml
.adb connect {ip-address}
(It may say failed to authenticate, just try again, it should say already connected).adb shell
.su
.whoami
. It should say "root". If it doesn't, something went wrong. You maybe missed a step or this has gone out of date.exit
twice.adb shell appops set tech.httptoolkit.android.v1 ACTIVATE_VPN allow
.openssl x509 -inform PEM -subject_hash_old -in C:\WSA\http-toolkit-ca-certificate.crt| head -1
.copy C:\WSA\http-toolkit-ca-certificate.crt C:\WSA\{cert-hash}.0
.copy C:\WSA\{msix-folder}\system.img C:\WSA\{msix-folder}\system.img.old
. Remember that {msix-folder} refers to the folder name you made via extraction in step 7.sudo mkdir /mnt/sysimg
.sudo mount -o loop /mnt/c/WSA/{msix-folder}/system.img /mnt/sysimg
.cd /mnt/sysimg/system/etc/security/cacerts
.sudo cp /mnt/c/WSA/{cert-hash}.0 {cert-hash}.0
.sudo chmod 644 {cert-hash}.0
.sudo chown root:root {cert-hash}.0
.cd /
.sudo umount /mnt/sysimg
. You can close WSL now if you like.adb kill-server
.adb connect {ip-address}
(It may say failed to authenticate, just try again, it should say already connected).Wow, amazing work @ethan-xd! Thanks so much for writing that all up, that's super useful :+1:
to conclude, you run adb shell appops set <tech.httptoolkit.android.v1> ACTIVATE_VPN allow
on a rooted (maybe not) WSA instance before doing the intercept / connecting to VPN
replace content in <>
for your VPN app
@ethan-xd Hey, thanks a lot for the in-depth guide. I'm currently trying to get it to work on the latest Retail WSA, which is actually Android 12 (2204.40000.19). Currently, rooting doesn't work (as per https://github.com/WSA-Community/WSA-Linux-Kernel/issues/7 and having tried it myself), but I still went on. The problem that I'm actually encountering is that the certificate doesn't actually work even after copying it to /cacerts
and giving it perms. The only thing I could think of is that it won't have the SELinux context like the other certs u:object_r:system_security_cacerts_file:s0
but can't really imagine that as the reason (also can't assign a context in WSL unfortunately).
The only thing that I haven't tried yet is getting an older version of WSA, but will have to look into 3rd party sources.
@ethan-xd Hey, thanks a lot for the in-depth guide. I'm currently trying to get it to work on the latest Retail WSA, which is actually Android 12 (2204.40000.19). Currently, rooting doesn't work (as per WSA-Community/WSA-Linux-Kernel#7 and having tried it myself), but I still went on. The problem that I'm actually encountering is that the certificate doesn't actually work even after copying it to
/cacerts
and giving it perms. The only thing I could think of is that it won't have the SELinux context like the other certsu:object_r:system_security_cacerts_file:s0
but can't really imagine that as the reason (also can't assign a context in WSL unfortunately).The only thing that I haven't tried yet is getting an older version of WSA, but will have to look into 3rd party sources.
https://github.com/LSPosed/MagiskOnWSA
you can get a rooted instance here
maybe it is a older version tho
@Blaconix Unfortunate to hear that the kernel file no longer works on Android 12. At the time I wrote it Retail was on 11.
You can look into MagiskOnWSA like what @YuenSzeHong said, but be careful: it broke my Windows 11 install by not loading WSA ever again no matter how much I uninstalled and reinstalled components of it. I had to reinstall Windows to fix it. LSPosed/MagiskOnWSA#396 for more info on my error.
Have you tried installing the certificate via the WSL mounting steps without rooting it? I'm not sure the whole process requires root, but I haven't tried it. Sorry I saw you did try that.
Also, @YuenSzeHong: I only just saw your previous message from 2 weeks ago, and the certificate auto-install on HTTP Toolkit didn't work for me even after I rooted. I had to install the certificate manually, because apparently the current versions of Android don't support installing the system certificates, but I could be wrong.
to conclude, you run
adb shell appops set <tech.httptoolkit.android.v1> ACTIVATE_VPN allow
on a rooted (maybe not) WSA instance before doing the intercept / connecting to VPN replace content in<>
for your VPN app
if you mean that method, thas unfortunate, because that was working for me back then, and i did the same to my destop, also had rooted wsa installed
adb shell appops set tech.httptoolkit.android.v1 ACTIVATE_VPN allow
still works to set HTTPToolkit as a VPN, but I believe their cert injection script (https://github.com/httptoolkit/httptoolkit-server/blob/main/src/interceptors/android/adb-commands.ts#L208-L262) doesn't work on Android 12
That's where the manual setup comes in to mount /cacerts
into WSL and add the certificate manually, however that still has no effect (here's me hoping I didn't do something stupid, but a ls -la
on that folder shows HTTPToolkit's cert with correct perms). I think I'll just try and find an old WSA version somewhere on the internet before trying to root with https://github.com/LSPosed/MagiskOnWSA since bricking the whole WSA feels like a bad choice.
I believe their cert injection script doesn't work on Android 12
That cert injection script (for system cert injection) does work on Android 12, everywhere I've tested (although I haven't tested WSL myself).
Those scripts require root access though. The error there that only occurs in cases where HTTP Toolkit can't detect the root access it expects to be able to run that script in the first place. In which case it falls back to installing user certificates, which is semi-automatic (a single prompt) in Android <11, and then mostly manual via those instructions in Android 12+.
Does that make sense? This means if you can set up WSL to give HTTP Toolkit root access, the system cert setup script should work automatically. It tests for root by running each of "su root whoami", "su -c whoami" and "adb root" + "whoami" via adb shells, and looking for the command that works and prints "root". I don't know how WSL handles all that though.
Thanks for clarifying! I rooted with https://github.com/LSPosed/MagiskOnWSA, then just ran HTTPToolkit with ADB and everything works without additional setup.
PS: I had to disable Advanced Networking in WSA Settings for HTTPToolkit to work correctly.
Rooted WSA can now be found at https://github.com/LSPosed/MagiskOnWSALocal and I can confirm that it is working great out of the box.
PS. For non-root WSA, you may use Microsoft Launcher (or other launcher) to go to setting and manually install CA cert (enable User Trust), but that's all I can do.
As the above reply says you can use MagiskOnWSALocal to install WSA with Magisk, you then can open Magisk and enable Superuser on shell, which will then allow HTTP Toolkit to install the certificate without warning you about Android 12.
it worked for me by using https://github.com/MustardChef/WSABuilds
to get wsa build with magisk already setup. then getting platform tools to use adb. I made sure to enable developer settings and bridge debugging in android settings. I connect adb then run adb shell appops set tech.httptoolkit.android.v1 ACTIVATE_VPN allow
. then I go to httptoolkit desktop app and press start intercepting with adb and it worked for me.
It seems that Microsoft are now officially killing WSA (https://www.osnews.com/story/138718/microsoft-kills-windows-subsystem-for-android/) and it will fully unsupported & unavailable for new users from March 2025. Given that, I don't think it's worth adding extra support for this, so I'm going to close this issue.
If you do want to use HTTP Toolkit with WSA regardless, see the instructions above for the best workaround in the meantime.
Unable to start http toolkit on windows subsystem for Android on windows 11 . Getting the following error
Anyway to resolve it?