jcheng31 / DarkSkyApi

An unofficial C# library for the Dark Sky weather service. Targets .NET Standard 1.1.
MIT License
32 stars 18 forks source link

Problem Accessing GetWeatherDataAsync #28

Open ManuAnalys opened 4 years ago

ManuAnalys commented 4 years ago

Hello,

We are using your nuget package to consume DarkSkyApi.

We have this code :

var client = new DarkSkyService(apiKey); Task taskWeatherData = client.GetWeatherDataAsync(latitudeAsDouble, longitudeAsDouble, Unit.CA, extendList, exclusionList, Language.French); taskWeatherData.Wait(); var forecastWeather = taskWeatherData.Result;

Since few days we have an exception on Wait procedure. (HttpRequestException, WebException, IOException, SocketException).

We have tried with several apiKy and Several latitude and longitude. The URL : https://api.darksky.net/forecast/b26c2949a2e9ffa9cfaa62183ed2c0c7/48.5586242184,2.43753236038 is working fine.

Do you have any explanation about that problem?

Thank you for your help.

ManuAnalys commented 4 years ago

I change to TLS12 and it is working fine

ManuAnalys commented 4 years ago

I got this email from DarkSky :

At 5 PM Eastern Standard Time on March 4th, we applied a few security updates in line with the recommendations of a recent security audit. As a result, we’ve dropped the following SSL protocols and ciphers: • TLS 1.0 • TLS 1.1 • TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA • TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA • TLS_RSA_WITH_AES_128_GCM_SHA256 • TLS_RSA_WITH_AES_128_CBC_SHA256 • TLS_RSA_WITH_AES_128_CBC_SHA • TLS_RSA_WITH_AES_256_GCM_SHA384 • TLS_RSA_WITH_AES_256_CBC_SHA256 • TLS_RSA_WITH_AES_256_CBC_SHA

These changes are likely to be the reason you are seeing that error. Once you've updated your SSL, you can test the API by sending a request here: https://api.darksky.net:4433/v1/status.txt. You can also determine whether your app works with the new SSL permissions by testing against https://api.darksky.net:4433/.

Note that we will be making additional security-related updates in the coming weeks so there will be more changes in the near future. We don't have a notification system for alerting users to changes made on our backend but we do offer a feed for our status page, which often includes information about updates that have been or will be made (https://status.darksky.net/). We'll do our very best to make sure we communicate them as we're able to. Additionally, to avoid future disruptions we strongly recommend switching to one of the following, which should carry you through any of the additional security updates that will be applied in the near future: • TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 • TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384

RBJensen1973 commented 4 years ago

Quick and dirty workaround: Extract the files from the "Portable" project to a new "clean" project. Then add :

ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

to DarkSkyService.cs, method

private async Task GetForecastFromUrlAsync(string requestUrl)