PDA

View Full Version : خطای the requested security protocol is not supported



mohan21
چهارشنبه 04 دی 1398, 18:18 عصر
سلام
وقت بخیر

من از کد زیر برای ارسال اطلاعات به سایت استفاده می کنم.



try
{
ServicePointManager.ServerCertificateValidationCal lback = delegate { return true; };
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Ssl3;


WebRequest req = WebRequest.Create(site);
req.ContentType = "application/x-www-form-urlencoded";
req.Method = "POST";
byte[] bytes = Encoding.UTF8.GetBytes("data=" + "null");
req.ContentLength = bytes.Length;
Stream os = req.GetRequestStream();
os.Write(bytes, 0, bytes.Length);
os.Close();
WebResponse resp = req.GetResponse();
StreamReader sr = new StreamReader(resp.GetResponseStream());


MessageBox.Show(sr.ReadToEnd().Trim());
}
catch (Exception exc)
{
MessageBox.Show(exc.Message.ToString());
}


برنامه روی کامپیوتر خودم مشکلی نداره اما روی کامپیوتر مشتری خطای the requested security protocol is not supported میدهد.

کد رو بصورت زیر تغییر دادم



try
{
WebRequest req = WebRequest.Create(site);
req.ContentType = "application/x-www-form-urlencoded";
req.Method = "POST";
byte[] bytes = Encoding.UTF8.GetBytes("data=" + "null");
req.ContentLength = bytes.Length;
Stream os = req.GetRequestStream();
os.Write(bytes, 0, bytes.Length);
os.Close();
WebResponse resp = req.GetResponse();
StreamReader sr = new StreamReader(resp.GetResponseStream());


MessageBox.Show(sr.ReadToEnd().Trim());
}
catch (Exception exc)
{
MessageBox.Show(exc.Message.ToString());
}


اما مجددا همان خطا رو داد.

سیستم عامل مشتری ویندوز 7 و دات نت 4 هم نصب شده است، با دات نت 4.5 هم تست کردم رفع نشد.

لطفن برای حل این مشکل راهنمایی بفرمایید.

محمد رضا فاتحی
چهارشنبه 04 دی 1398, 21:11 عصر
اینو یه بررسی بکنید
https://kb.vmware.com/articleview?docid=2147909

mohan21
پنج شنبه 05 دی 1398, 11:08 صبح
مشکل با استفاده فقط از SecurityProtocolType.Tls حل شد.


ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls