所谓的潇洒

导航

未能创建 SSL/TLS 安全通道

服务端用了自签名证书,客户端需带上证书去请求

                ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(CheckValidationResult);//验证服务器证书回调自动验证
                X509Certificate cer1 = new X509Certificate("client.pfx", "123456");
                request.ClientCertificates.Add(cer1);

public static bool CheckValidationResult(object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate,
System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors errors)
{ // 总是接受
return true;
}

试了很多方法总是报“未能创建 SSL/TLS 安全通道”等错误

解决步骤:

1.安装证书到本地计算机账号

2.将项目.net版本升到4.6

posted on 2022-03-25 11:39  所谓的潇洒  阅读(1179)  评论(0编辑  收藏  举报