Fix Mono 4.8+

This commit is contained in:
JustArchi
2016-10-01 23:16:44 +02:00
parent b613b5ab38
commit a261dc44fd
2 changed files with 19 additions and 0 deletions

View File

@@ -127,6 +127,21 @@ namespace ArchiSteamFarm {
}
}
// TODO: Remove me once BTLS in Mono 4.8+ is fixed
internal static bool RequiresNoCertificateValidation() {
if (!IsRunningOnMono) {
return false;
}
Version monoVersion = GetMonoVersion();
if (monoVersion?.Major != 4) {
return false;
}
return monoVersion.Minor >= 8;
}
private static Version GetNetVersion() {
uint release;
using (RegistryKey registryKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32).OpenSubKey("SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v4\\Full\\")) {

View File

@@ -54,6 +54,10 @@ namespace ArchiSteamFarm {
// Don't use Expect100Continue, we're sure about our POSTs, save some TCP packets
ServicePointManager.Expect100Continue = false;
if (Runtime.RequiresNoCertificateValidation()) {
ServicePointManager.ServerCertificateValidationCallback += (s, ce, ca, p) => true;
}
#if !__MonoCS__
// We run Windows-compiled ASF on both Windows and Mono. Normally we'd simply put code in the if
// However, if we did that, then we would still crash on Mono due to potentially calling non-existing methods