fix(Override certificate pinning): Always overwrite with a generic network security configuration
Previously some conditional checks prevented to patch YouTube for example. The current configuration should work globally for all apps.
This commit is contained in:
parent
020c642761
commit
2a842a1e14
|
@ -4,6 +4,7 @@ import app.revanced.patcher.data.ResourceContext
|
||||||
import app.revanced.patcher.patch.ResourcePatch
|
import app.revanced.patcher.patch.ResourcePatch
|
||||||
import app.revanced.patcher.patch.annotation.Patch
|
import app.revanced.patcher.patch.annotation.Patch
|
||||||
import app.revanced.patches.all.misc.debugging.EnableAndroidDebuggingPatch
|
import app.revanced.patches.all.misc.debugging.EnableAndroidDebuggingPatch
|
||||||
|
import app.revanced.util.Utils.trimIndentMultiline
|
||||||
import org.w3c.dom.Element
|
import org.w3c.dom.Element
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
|
@ -32,10 +33,8 @@ object OverrideCertificatePinningPatch : ResourcePatch() {
|
||||||
|
|
||||||
// In case the file does not exist create the "network_security_config.xml" file.
|
// In case the file does not exist create the "network_security_config.xml" file.
|
||||||
File(resXmlDirectory, "network_security_config.xml").apply {
|
File(resXmlDirectory, "network_security_config.xml").apply {
|
||||||
if (!exists()) {
|
writeText(
|
||||||
createNewFile()
|
"""
|
||||||
writeText(
|
|
||||||
"""
|
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<network-security-config>
|
<network-security-config>
|
||||||
<base-config cleartextTrafficPermitted="true">
|
<base-config cleartextTrafficPermitted="true">
|
||||||
|
@ -55,21 +54,8 @@ object OverrideCertificatePinningPatch : ResourcePatch() {
|
||||||
</trust-anchors>
|
</trust-anchors>
|
||||||
</debug-overrides>
|
</debug-overrides>
|
||||||
</network-security-config>
|
</network-security-config>
|
||||||
""",
|
""".trimIndentMultiline(),
|
||||||
)
|
)
|
||||||
} else {
|
|
||||||
// If the file already exists.
|
|
||||||
readText().let { text ->
|
|
||||||
if (!text.contains("<certificates src=\"user\" />")) {
|
|
||||||
writeText(
|
|
||||||
text.replace(
|
|
||||||
"<trust-anchors>",
|
|
||||||
"<trust-anchors>\n<certificates src=\"user\" overridePins=\"true\" />\n<certificates src=\"system\" />",
|
|
||||||
),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue