该请求已中止:无法创建SSL/TLS安全通道沙箱帐户

问题描述:

一周前它运行良好,但现在显示以下错误.我尝试了以下操作,但没有用.

It was working well before a week but now it shows following error. I have tried the following things but of no use.

ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;

所以建议我可能的解决方法

so suggest me with possible solution

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

        ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
        // allows for validation of SSL conversations
        ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };


        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 e)
        {
            /*
            if (log.IsFatalEnabled)
            {
                log.Fatal(e.Message, this);
            }*/
        }

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

        //Logging the response of the transaction
        /* if (log.IsInfoEnabled)
         {
             log.Info("Result :" +
                       " Elapsed Time : " + (DateTime.Now - startDate).Milliseconds + " ms" +
                      result);
         }
         */
        return result;
    }

我也在测试环境中遇到了同样的问题(幸运的是,我的实时付款正在进行中).我通过更改来解决它:

I just ran into this same problem in my testing environment as well (luckily my live payments are going through). I fixed it by changing:

public PayPalAPI(string specialAccount = "")
{
    System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls;

public PayPalAPI(string specialAccount = "")
{
    System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;

不久前,他们禁用了对SSL3的支持: https://www .paypal.com/uk/webapps/mpp/ssl-security-update ,具体说明

They disabled support for SSL3 a while ago: https://www.paypal.com/uk/webapps/mpp/ssl-security-update, specifically stating

确保使用TLS 1.0或1.2连接到PayPal端点 (并非目前所有的API端点都支持TLS 1.1).

Ensure you are connecting to PayPal endpoints using TLS 1.0 or 1.2 (not all API endpoints currently support TLS 1.1).

他们的最新更新(来自@awesome的评论更新为thx)指出:

Their latest update (thx for the comment update from @awesome) states:

PayPal正在更新其服务,以要求所有HTTPS都使用TLS 1.2 连接.目前,贝宝(PayPal)还将要求所有HTTP/1.1 连接... 为避免服务中断,您必须在2016年6月17日之前确认系统已准备好进行此更改

PayPal is updating its services to require TLS 1.2 for all HTTPS connections. At this time, PayPal will also require HTTP/1.1 for all connections... To avoid any disruption of service, you must verify that your systems are ready for this change by June 17, 2016