Witam
Może jakiś magik mi pomoże. Używałem poniższego kodu do pobierania źródła strony przez dobre 5 lat, ale jakieś 2-3 tygodnie temu ta metoda przestała działać. Teraz cały czas zwraca błąd: "The request was aborted: Could not create SSL/TLS secure channel.". W google znalazlem wszędzie jedno i to samo, żeby dodać SecurityProtocol dla tls 1.2, ale nic to nie dalo. Ma ktoś jakiś pomysł jak to naprawić?
Kod:
using System;
using System.IO;
using System.Net;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
try
{
string jsonUrl = "https://store.playstation.com/store/api/chihiro/00_09_000/container/GB/en/999/EP0177-CUSA05674_00-SONIC20170000000/";
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; }; // win xp fix
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072 | (SecurityProtocolType)768 | SecurityProtocolType.Tls | SecurityProtocolType.Ssl3;
using (WebClient wc = new WebClient())
{
wc.Proxy = null; // win xp fix
wc.Encoding = Encoding.UTF8;
//wc.Headers.Add(HttpRequestHeader.UserAgent, "My app.");
//wc.Headers.Add(HttpRequestHeader.UserAgent, "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:71.0) Gecko/20100101 Firefox/71.0");
StringBuilder jsonSB = new StringBuilder(Convert.ToString(wc.DownloadString(jsonUrl)));
File.WriteAllText("jsonTest.txt", jsonSB.ToString());
jsonSB.Remove(0, jsonSB.Length);
}
}
catch (WebException ex)
{
Console.WriteLine("BLAD: " + ex.Message);
return;
}
Console.WriteLine("Gotowe.");
}
}
}
Curl pobiera źródło bez żadnych problemów na Win XP i Win 7
curl.exe --insecure --request GET "https://store.playstation.com/store/api/chihiro/00_09_000/container/GB/en/999/EP0177-CUSA05674_00-SONIC20170000000/" --output "json.txt"
Pozdrawiam