|
1 | 1 | using System; |
2 | 2 | using System.Diagnostics; |
3 | 3 | using System.IO; |
| 4 | +using System.Linq; |
4 | 5 | using System.Net; |
5 | 6 | using System.Reflection; |
6 | 7 | using System.Text; |
7 | 8 | using System.Windows.Forms; |
8 | 9 |
|
9 | 10 | namespace OpenHardwareMonitor.Utilities |
10 | 11 | { |
11 | | - |
12 | 12 | public class GitHubRelease |
13 | 13 | { |
14 | 14 | public Uri assets_url { get; set; } |
@@ -50,6 +50,9 @@ static Updater() |
50 | 50 | CurrentVersion = asm.GetName().Version.ToString(3); //Application.ProductVersion; |
51 | 51 | CurrentFileLocation = asm.Location; |
52 | 52 | selfFileName = Path.GetFileName(CurrentFileLocation); |
| 53 | + ServicePointManager.Expect100Continue = false; |
| 54 | + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; |
| 55 | + ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true; |
53 | 56 | } |
54 | 57 |
|
55 | 58 | private static string GetJsonData(string uri, int timeout = 10, string method = "GET") |
@@ -88,8 +91,9 @@ internal static void CheckForUpdates(bool silent) |
88 | 91 | if (releases == null || releases.Length == 0) |
89 | 92 | throw new Exception("Error getting list of releases."); |
90 | 93 |
|
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; |
93 | 97 |
|
94 | 98 | if (string.Compare(CurrentVersion, newVersion, StringComparison.Ordinal) >= 0) |
95 | 99 | { |
|
0 commit comments