0
我有一個使用客戶端證書製作HttpWebRequest的小型Windows應用程序。客戶端要求在請求中包含X509Certificate(.cer文件自簽名證書)。但是iam得到以下錯誤「請求被中止,不能創建SSL/TLS安全通道。」我甚至嘗試使用.pfx文件,但得到相同的錯誤。和下面是用於該代碼的相同:無法創建SSL/TLS安全通道。請求已中止c#
ServicePointManager.ServerCertificateValidationCallback = 委託(對象OBJ,X509證書證書,X509Chain鏈,SslPolicyErrors錯誤) { //信任任何證書 返回真; }; ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
string certPath1 = @"C:\tmpVenDXCCert.cer";
X509Certificate xc = new X509Certificate(certPath1, "[email protected]");
HttpWebRequest Request = (HttpWebRequest)
WebRequest.Create("https://the-payments-place.com:8449");
Request.ClientCertificates.Add(xc);
Request.UserAgent = "Client Cert Sample";
Request.Method = "GET";
HttpWebResponse Response = (HttpWebResponse)Request.GetResponse();
任何幫助將不勝感激。
問候,
拉姆