asp.net - 无法创建 SSL/TLS 安全通道 - GetRequestStream()

标签 asp.net ssl paypal

我正在尝试将 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/

相关文章:

python - 使用 python pvlib 库时出现 SSL 证书错误

c# - 绕过证书验证

silverlight - WCF RIA 服务和通过 SSL 通信

mysql - 交替日期和付款单元格的搜索范围

c# - 似乎没有为 __doPostBack 发出正确的 GridView 标记

c# - 在 ASP.NET WebForm 中输入按键事件执行按钮点击

asp.net - 如何阻止我的 ASP.NET Web 服务返回 xml 数据?

perl - PayPal Express 客户结账交易 ID

transactions - 如何使用一些 API 下载 Paypal 交易

html - 大型 html 表格速度慢吗?