简体   繁体   English

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

[英]Could not create SSL/TLS secure channel - GetRequestStream()

I am trying to integrate paypal into a web application and I've not been successful. 我试图将Paypal集成到Web应用程序中,但没有成功。 I have tried loads of things but I keep coming back to one particular error. 我已经尝试了很多事情,但我不断回到一个特定的错误。 I am now trying to use the paypal integration wizard, and when I get the code that is provided, I get an error that says: The request was aborted: Could not create SSL/TLS secure channel. 我现在正在尝试使用贝宝集成向导,并且在获得所提供的代码时,出现错误消息:请求已中止:无法创建SSL / TLS安全通道。

This is the code: 这是代码:

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());

The error occurs on the last line, on the objRequest.GetRequestStream() 错误发生在objRequest.GetRequestStream()的最后一行

I tried looking it up on google but I didn't find anything that worked for me. 我尝试在Google上查找它,但没有找到对我有用的东西。 Does anybody know what I can do to fix this? 有人知道我该怎么做才能解决此问题吗?

Add the following code to your global.asax.cs Application_Started method or before calling the (HttpWebRequest)WebRequest.Create(url); 将以下代码添加到您的global.asax.cs Application_Started方法中,或者在调用(HttpWebRequest)WebRequest.Create(url);之前添加以下代码。

    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

This was caused because PayPal are changing their encryption to TLS instead of SSL. 这是因为PayPal将其加密更改为TLS而不是SSL。 This has already been updated on the Sandbox environments but not yet on the live. 在Sandbox环境中已对此进行了更新,但尚未进行实时更新。

Read more: https://devblog.paypal.com/upcoming-security-changes-notice/ 了解更多: https//devblog.paypal.com/upcoming-security-changes-notice/

我在另一个站点上遇到了完全相同的问题,但是对我来说这没有用,但是以下方法可以解决:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 TLS 1.2错误无法创建SSL / TLS安全通道 - TLS 1.2 error Could not create SSL/TLS secure channel XmlReader.Create错误“无法创建SSL / TLS安全通道” - XmlReader.Create error “Could not create SSL/TLS secure channel” 无法创建SSL / TLS安全通道。 -Cdyne回传 - Could not create SSL/TLS secure channel. - Cdyne Postback ASP.NET,HttpWebRequest和“无法创建SSL / TLS安全通道” - ASP.NET, HttpWebRequest and “Could not create SSL/TLS secure channel” WebException:请求已中止:无法创建SSL / TLS安全通道 - WebException: The request was aborted: Could not create SSL/TLS secure channel HttpWebRequest:请求已中止:无法创建SSL / TLS安全通道 - HttpWebRequest: The request was aborted: Could not create SSL/TLS secure channel 请求被中止:无法创建 SSL/TLS 安全通道 - The request was aborted: Could not create SSL/TLS secure channel Braintree 中的“请求被中止:无法创建 SSL/TLS 安全通道”错误 - "The request was aborted: Could not create SSL/TLS secure channel" error in Braintree “无法创建SSL / TLS安全通道”:克隆如何工作? - “Could not create SSL/TLS secure channel”: how can the clone work? 无法创建从插件到Web服务的SSL / TLS安全通道 - Could not create SSL/TLS secure channel from plugin to web service
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM