webApi Authentication failed because the remote party has closed the transport stream\身份验证失败了,因为远程方关闭了传输流。

public class CertificateTrust
    {
        public static void SetCertificatePolicy()
        {
//当在浏览器中可以正常访问,而code中出现错误时,可以用fiddle看下正常访问的SSl加密认证的版本号 ServicePointManager.SecurityProtocol
= SecurityProtocolType.Tls12; ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(CheckValidationResult); } public static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors) { return true; } }

连接client之前调用
CertificateTrust.SetCertificatePolicy();

posted @ 2018-03-19 15:05  ~扎克伯格  阅读(...)  评论(...编辑  收藏