From eb299fef1d35a1329ff695652bb2ef9c23726be0 Mon Sep 17 00:00:00 2001 From: js6pak Date: Sun, 4 Apr 2021 22:18:03 +0200 Subject: [PATCH] Accept all public keys --- Reactor/Networking/Patches/AuthPatches.cs | 27 +++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Reactor/Networking/Patches/AuthPatches.cs diff --git a/Reactor/Networking/Patches/AuthPatches.cs b/Reactor/Networking/Patches/AuthPatches.cs new file mode 100644 index 0000000..da5d296 --- /dev/null +++ b/Reactor/Networking/Patches/AuthPatches.cs @@ -0,0 +1,27 @@ +using System.Linq; +using HarmonyLib; +using Hazel.Dtls; +using Il2CppSystem.Security.Cryptography.X509Certificates; + +namespace Reactor.Networking.Patches +{ + internal static class AuthPatches + { + [HarmonyPatch(typeof(X509Certificate2Collection), nameof(X509Certificate2Collection.Contains))] + public static class AcceptCustomCertificatesPatch + { + public static bool Prefix(ref bool __result) + { + var caller = new Il2CppSystem.Diagnostics.StackTrace().GetFrames().First().GetMethod(); + + if (caller.DeclaringType.FullName == typeof(DtlsUnityConnection).FullName && caller.Name == nameof(DtlsUnityConnection.ProcessHandshake)) + { + __result = true; + return false; + } + + return true; + } + } + } +}