c# – HttpWebRequest:请求已中止:无法创建SSL / TLS安全通道
我正在制作一个asp.net网络表单应用程序,它提供使用paypal支付.该应用程序应该使用ssl.当我运行我的应用程序一切顺利,直到我选择我的按钮paypal支付.当我按下此按钮时,会出现以下错误:
在我的错误发生的方法下面 public string HttpCall(string NvpRequest) { string url = pEndPointURL; string strPost = NvpRequest + "&" + buildCredentialsNVPString(); strPost = strPost + "&BUTTONSOURCE=" + HttpUtility.UrlEncode(BNCode); HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url); objRequest.Timeout = Timeout; objRequest.Method = "POST"; //objRequest.ContentLength = strPost.Length; try { using (StreamWriter myWriter = new StreamWriter(objRequest.GetRequestStream())) { myWriter.Write(strPost); } } catch (Exception) { // No logging for this tutorial. } //Retrieve the Response returned from the NVP API call to PayPal. HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse(); string result; using (StreamReader sr = new StreamReader(objResponse.GetResponseStream())) { result = sr.ReadToEnd(); } return result; } 解决方法
您的代码段未指定要使用的安全协议 – 我可以告诉您 –
例: ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; 我在针对paypal api查看不同的身份验证方法后发现了这一点. 这里有一个相关的话题值得信赖. problems-with-paypal-api-http-call 注意:在原始OP问题的一系列评论之后添加了这个答案. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |