I am getting error "The request was aborted: Could not create SSL/TLS secure channel." in case of sandbox however this works with my live credentials.
here is the code snippet
var uri = new Uri(url);
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
var request = WebRequest.Create(uri);
var encoding = new UTF8Encoding();
var requestData = encoding.GetBytes(postData);
request.ContentType = "application/x-www-form-urlencoded";
request.Method = "POST";
request.Timeout = (300 * 1000); //TODO: Move timeout to config
request.ContentLength = requestData.Length;
using (var stream = request.GetRequestStream())
{
stream.Write(requestData, 0, requestData.Length);
}
var response = request.GetResponse();
string result;
using (var reader = new StreamReader(response.GetResponseStream(), Encoding.ASCII))
{
result = reader.ReadToEnd();
}
return result;
The problem is C# defaults to SSL3 when trying to connect to the PayPal server, which PayPal doesn't accept. PayPal requires the (more secure) TLS 1.2 as a minimum.
You set this through the following code:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.