C# HttpClient An existing connection was forcibly closed by the remote host

后端 未结 5 938
一生所求
一生所求 2020-12-15 02:37

I\'m working on an integration with Alternative Payments using their hosted page integration. Their C# SDK does not have this integration available at the moment, but as you

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-15 03:16

    This worked for me, the first line ensures the protocols ssl3 and TLS1.2, and the second line ignores any potential certificate errors (ignore and continue - like expired certs.):

    ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12;
    ServicePointManager.ServerCertificateValidationCallback +=  (sender, certificate, chain, sslPolicyErrors) => true;
    

提交回复
热议问题