Skip to content

Commit fe968d5

Browse files
committed
updater - tls12 + ignore prereleases
1 parent fbe2114 commit fe968d5

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

OpenHardwareMonitor/Utilities/Updater.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
using System;
22
using System.Diagnostics;
33
using System.IO;
4+
using System.Linq;
45
using System.Net;
56
using System.Reflection;
67
using System.Text;
78
using System.Windows.Forms;
89

910
namespace OpenHardwareMonitor.Utilities
1011
{
11-
1212
public class GitHubRelease
1313
{
1414
public Uri assets_url { get; set; }
@@ -50,6 +50,9 @@ static Updater()
5050
CurrentVersion = asm.GetName().Version.ToString(3); //Application.ProductVersion;
5151
CurrentFileLocation = asm.Location;
5252
selfFileName = Path.GetFileName(CurrentFileLocation);
53+
ServicePointManager.Expect100Continue = false;
54+
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
55+
ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;
5356
}
5457

5558
private static string GetJsonData(string uri, int timeout = 10, string method = "GET")
@@ -88,8 +91,9 @@ internal static void CheckForUpdates(bool silent)
8891
if (releases == null || releases.Length == 0)
8992
throw new Exception("Error getting list of releases.");
9093

91-
newVersion = releases[0].tag_name;
92-
newVersionUrl = releases[0].assets[0].browser_download_url;
94+
var lastRelease = releases.FirstOrDefault(r => !r.prerelease) ?? releases[0];
95+
newVersion = lastRelease.tag_name;
96+
newVersionUrl = lastRelease.assets[0].browser_download_url;
9397

9498
if (string.Compare(CurrentVersion, newVersion, StringComparison.Ordinal) >= 0)
9599
{

0 commit comments

Comments
 (0)