Hi. I'm upgrading NOP from 3.30. to 3.90. Everythings works fine except a plugin payment customized by me that execute a webrequest.
Below is the code that work on a test installation: it runs well for 3.30 but not for 3.90.
An exception of "Could not create SSL/TLS secure channel." at this line "Stream sout = req.GetRequestStream()"
I'm becoming crazy !!!
public static string HttpPost(string url, string postData, string saveTo = "")
{
postData = postData.Replace("\r\n", "");
try
{
WebRequest req = WebRequest.Create(url);
byte[] send = Encoding.Default.GetBytes(postData);
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
//req.ContentType = "text/xml;charset=\"utf-8\"";
req.ContentLength = send.Length;
//--------------------> HERE exception is thrown
Stream sout = req.GetRequestStream();
//-------------------->
sout.Write(send, 0, send.Length);
sout.Flush();
sout.Close();
WebResponse res = req.GetResponse();
StreamReader sr = new StreamReader(res.GetResponseStream());
string returnvalue = sr.ReadToEnd();
if (!string.IsNullOrEmpty(saveTo))
File.WriteAllText(saveTo, returnvalue);
//Debug.WriteLine("{0}\n{1}", postData, returnvalue);
return returnvalue;
}
catch (Exception ex)
{
return ex.Message.ToString();
}
}