2016-01-22 17 views
34

Nó hoạt động tốt trước một tuần nhưng giờ nó hiển thị lỗi sau. Tôi đã thử những điều sau đây nhưng không sử dụng.Yêu cầu bị hủy: Không thể tạo tài khoản sandbox kênh bảo mật SSL/TLS

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

nên gợi ý cho tôi với giải pháp khả thi

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; 
    } 
+0

Bất kỳ cập nhật về vấn đề này? Tôi cũng đang phải đối mặt với cùng một vấn đề. – Saurabh

Trả lời

35

Tôi chỉ chạy vào cùng một vấn đề này trong môi trường thử nghiệm của tôi cũng (may mắn là thanh toán trực tiếp của tôi đang trải qua). Tôi cố định nó bằng cách thay đổi:

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

để

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

Họ hỗ trợ người khuyết tật cho SSL3 một thời gian cách đây: https://www.paypal.com/uk/webapps/mpp/ssl-security-update, cụ thể nêu

Đảm bảo bạn đang kết nối với điểm cuối PayPal sử dụng TLS 1.0 hoặc 1.2 (không phải tất cả các điểm cuối API hiện hỗ trợ TLS 1.1).

họ latest update (thx for the update bình luận từ @awesome) khẳng định:

PayPal đang cập nhật dịch vụ của mình để yêu cầu TLS 1.2 cho tất cả HTTPS kết nối. Tại thời điểm này, PayPal cũng sẽ yêu cầu HTTP/1.1 cho tất cả các kết nối ... Để tránh bất kỳ sự gián đoạn của dịch vụ, bạn phải xác minh rằng hệ thống của bạn đã sẵn sàng cho sự thay đổi này bằng 17 tháng 6 năm 2016

+1

Tin chính thức https://www.paypal-knowledge.com/infocenter/index?page=content&widgetview=true&id=FAQ1914&viewlocale=en_US –

+0

Cảm ơn đống! Đúng thứ tôi cần. – Brendan

22

Trên thực tế thay đổi SecurityProtocolType.Tls khắc phục sự cố, nếu bạn đang làm việc trong VS với khung thấp hơn 4.5, bạn sẽ không thể thay đổi nó, bạn phải nâng cấp VS lên phiên bản cao nhất 2012/2013/2015 để thay đổi nó.

System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType. Tls12;

+27

Thực ra bạn * có thể * sử dụng nó (ít nhất là 4.0) như sau: 'ServicePointManager.SecurityProtocol = (SecurityProtocolType) 3072; // SecurityProtocolType.Tls12' –

+0

@ James McCormack: cảm ơn rất tốt, có một sự thăng hoa. –

+0

Điều này rất hữu ích @JamesMcCormack – scgough

7

Thêm mã sau vào global.asax của bạn hoặc trước khi gọi (HttpWebRequest) WebRequest.Create (url);

protected void Application_Start() 
{ 
    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; 
    // ... 
} 

Điều này là do PayPal đang thay đổi mã hóa của họ thành TLS thay vì SSL. Điều này đã được cập nhật trên môi trường Sandbox nhưng chưa được cập nhật.

Read more: https://devblog.paypal.com/upcoming-security-changes-notice/

Các vấn đề liên quan