diff --git a/src/NetSparkle/Downloaders/WebRequestAppCastDataDownloader.cs b/src/NetSparkle/Downloaders/WebRequestAppCastDataDownloader.cs index 250836d1..c1c6c8cf 100644 --- a/src/NetSparkle/Downloaders/WebRequestAppCastDataDownloader.cs +++ b/src/NetSparkle/Downloaders/WebRequestAppCastDataDownloader.cs @@ -79,8 +79,12 @@ public async Task DownloadAndGetAppCastDataAsync(string url) { _appcastUrl = url; // configure ssl cert link + // .NET 9 -> ServicePointManager is deprecated + // we have the lambda below for trusting all connections anyway, so this + // is sort of redundant at the moment. +#if NETSTANDARD || NET6 || NET7 || NET8 ServicePointManager.ServerCertificateValidationCallback += ValidateRemoteCertificate; - +#endif var handler = new HttpClientHandler(); if (RedirectHandler != null) { @@ -111,7 +115,10 @@ public async Task DownloadAndGetAppCastDataAsync(string url) if (response.IsSuccessStatusCode) { Stream responseStream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); + // .NET 9 -> ServicePointManager is deprecated +#if NETSTANDARD || NET6 || NET7 || NET8 ServicePointManager.ServerCertificateValidationCallback -= ValidateRemoteCertificate; +#endif using (StreamReader reader = new StreamReader(responseStream, GetAppCastEncoding())) { return await reader.ReadToEndAsync().ConfigureAwait(false); @@ -143,8 +150,10 @@ public async Task DownloadAndGetAppCastDataAsync(string url) } else { - Stream responseStream = await httpClient.GetStreamAsync(url).ConfigureAwait(false); + Stream responseStream = await httpClient.GetStreamAsync(url).ConfigureAwait(false);// .NET 9 -> ServicePointManager is deprecated +#if NETSTANDARD || NET6 || NET7 || NET8 ServicePointManager.ServerCertificateValidationCallback -= ValidateRemoteCertificate; +#endif using (StreamReader reader = new StreamReader(responseStream, GetAppCastEncoding())) { return await reader.ReadToEndAsync().ConfigureAwait(false); diff --git a/src/NetSparkle/SparkleUpdater.cs b/src/NetSparkle/SparkleUpdater.cs index dda36c66..b94c08e1 100644 --- a/src/NetSparkle/SparkleUpdater.cs +++ b/src/NetSparkle/SparkleUpdater.cs @@ -150,11 +150,19 @@ public SparkleUpdater(string appcastUrl, ISignatureVerifier signatureVerifier, s #region Properties +#if NETSTANDARD || NET6 || NET7 || NET8 /// /// The security protocol used by NetSparkle. Setting this property will also set this - /// for the current AppDomain of the caller. Needs to be set to - /// SecurityProtocolType.Tls12 for some cases (such as when downloading from GitHub). - /// + /// for the current AppDomain of the caller. May need to be set to + /// SecurityProtocolType.Tls12 for some cases (such as when downloading from GitHub); + /// however, if your app is using a more recent version of .NET, you should be OK. + /// See also: https://stackoverflow.com/a/59398678/3938401 + /// .NET 9 -> ServicePointManager is deprecated + /// + [Obsolete("Deprecated in .NET 9; this property may be removed at any time " + + "(including minor/patch updates to this library); override pertinent " + + "functions (e.g. to HttpClient) in WebRequestAppCastDataDownloader or " + + "similar to make equivalent changes to your application")] public SecurityProtocolType SecurityProtocolType { get @@ -166,6 +174,7 @@ public SecurityProtocolType SecurityProtocolType ServicePointManager.SecurityProtocol = value; } } +#endif /// /// Set the user interaction mode for Sparkle to use when there is a valid update for the software