我正在尝试将 paypal 集成到 Web 应用程序中,但没有成功。我已经尝试了很多东西,但我总是回到一个特定的错误。我现在正在尝试使用 paypal 集成向导,当我获得提供的代码时,我收到一条错误消息:请求已中止:无法创建 SSL/TLS 安全通道。
这是代码:
public string HttpCall(string NvpRequest) //CallNvpServer
{
string url = pendpointurl;
//To Add the credentials from the profile
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;
StreamWriter myWriter = new StreamWriter(objRequest.GetRequestStream());
错误发生在最后一行,在 objRequest.GetRequestStream() 上
我试着在谷歌上查找它,但没有找到适合我的东西。 有人知道我能做些什么来解决这个问题吗?
最佳答案
将以下代码添加到您的 global.asax.cs Application_Started 方法或调用 (HttpWebRequest)WebRequest.Create(url) 之前;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
这是因为 PayPal 正在将其加密更改为 TLS 而不是 SSL。这已在沙盒环境中更新,但尚未在实时环境中更新。
阅读更多: https://devblog.paypal.com/upcoming-security-changes-notice/
关于asp.net - 无法创建 SSL/TLS 安全通道 - GetRequestStream(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36574711/