Próbuje połączyć się z stroną https://www.empik.com/pure-country-various-artists,prod61080303,muzyka-p, niestety bezskutecznie wyświetla się komunikat:
An unhandled exception of type 'System.Net.WebException' occurred in System.dll
Additional information: The request was aborted: The connection was closed unexpectedly.
Kod źródłowy:
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using System.IO;
namespace EMPIK
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
ServicePointManager.ServerCertificateValidationCallback += ValidateRemoteCertificate;
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
WebClient MyWebClient = new WebClient();
var MyStream = MyWebClient.OpenRead(@"https://www.empik.com/pure-country-various-artists,prod61080303,muzyka-p");
StreamReader MyStreamReader = new StreamReader(MyStream);
string Page = MyStreamReader.ReadToEnd();
}
private static bool ValidateRemoteCertificate(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors error)
{
// If the certificate is a valid, signed certificate, return true.
// MessageBox.Show(chain.ToString());
if (error == System.Net.Security.SslPolicyErrors.None)
{
return true;
}
MessageBox.Show("X509Certificate [{0}] Policy Error: '{1}'" + cert.Subject, error.ToString());
return false;
}
}
}
Czy to ma jakiś związek z tls 13 (jestem poczatkujacym programistą ...)
Proszę o pomoc