Reputation: 181
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);
}
Upvotes: 15
Views: 139724
Reputation: 1
I faced similar Issue, now I am able to populate schema and rebuild indexes. Note: Make sure IIS is Stopped and all Solr services in services stopped. <services.msc>
steps 1: Did switch to Linux container in docker and switched back to previous. step 2: Executed down.ps1 and below list in Windows Powershell in Admin Mode
Stop-Service docker
Stop-service hns
Start-service hns
Start-Service docker
docker network prune
step 3: then Execute docker/clean.ps1 step 4: Execute \init.ps1 step 5: Execute docker-compose up -d and up.ps1.
Not sure the flow consideration on actual steps but it started populating and building index for my setup.
Upvotes: 0
Reputation: 15701
I believe we may have solved this exact issue (or one very similar)
In our case we got the same exception, but strangely from only a single machine.
After some investigation, we used this software (https://www.nartac.com/Products/IISCrypto/Download) to determine that there were no shared cipher suites between our box and the one we were attempting to contact.
We used the software to enable a supported suite on our box and rebooted.
Once back up and running, everything worked fine.
Ultimately this was a machine configuration issue and not a coding one.
[Note: I have no affiliation with this software or it's company, and I'm sure other methods could be used to achieve this, but I know this worked one for us]
Upvotes: 2
Reputation: 49
Before use HttpClient you should setup HttpClientHandler;
var handler = new HttpClientHandler();
handler.ServerCertificateCustomValidationCallback +=
(sender, certificate, chain, errors) =>
{
return true;
};
only than your HttpClient code. Must Work for .net Core 3.*
Upvotes: 3
Reputation: 181
After some time i figured that the library i was using was a bit bad. And after that i discovered Selenium.
With that in mind i started using Selenium WebDriver and figured that i can take a screenshot of a page i needed, then i cropped that image and i got what i needed.
So theres no need to continue this issue.
Upvotes: -2
Reputation: 151
I found te solution this blog helped me
ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, errors) =>
{
// local dev, just approve all certs
if (development) return true;
return errors == SslPolicyErrors.None ;
};
https://www.khalidabuhakmeh.com/validate-ssl-certificate-with-servicepointmanager
Upvotes: 6