使用HttpWebRequest请求http链接时,无法访问的问题,设置ServicePointManager.SecurityProtocol安全协议
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
[SecurityCritical] [SecuritySafeCritical] private static void InitialSecurityProtocol() { try { ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | (SecurityProtocolType)0x300 // Tls11 | (SecurityProtocolType)0xC00 // Tls12 | (SecurityProtocolType)0x3000; // Tls13 } catch (Exception) { try { ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | (SecurityProtocolType)0x300 // Tls11 | (SecurityProtocolType)0xC00; // Tls12 } catch (Exception) { try { ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | (SecurityProtocolType)0x300; // Tls11 } catch (Exception) { try { ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls; } catch (Exception) { } } } } }
欢迎加群交流 QQ群 : 830426796