Pal*_*veR 5 .net c# ssl avatar
I want to download osu! avatars to use them, but keep getting this error:
The SSL connection could not be established.
Inner exception is:
System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception. ---> System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception. ---> System.ComponentModel.Win32Exception: ???????? ?????????????? ????????? ??? ??? ????? ???????????? ??????
Example url: https://a.ppy.sh/10638551?1524507784.png
I tried using HttpClient and WebClient but without any success.
using(HttpClient client = new HttpClient())
{
var resp = await client.GetAsync("https://a.ppy.sh/10638551?1547998515.jpeg");
var responseStr = await resp.Content.ReadAsStringAsync();
File.WriteAllText("html/avatars/avatar.jpeg", responseStr);
}
Run Code Online (Sandbox Code Playgroud)
小智 6
我找到了这个博客帮助我的解决方案
ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, errors) =>
{
// local dev, just approve all certs
if (development) return true;
return errors == SslPolicyErrors.None ;
};
Run Code Online (Sandbox Code Playgroud)
https://www.khalidabuhakmeh.com/validate-ssl-certificate-with-servicepointmanager
| 归档时间: |
|
| 查看次数: |
37350 次 |
| 最近记录: |