Skip to content

Commit a4dcf11

Browse files
committed
Reoder code and classes
1 parent e3501ef commit a4dcf11

10 files changed

Lines changed: 2398 additions & 2357 deletions

src/SignToolGUI/Class/CertificateMonitor.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ namespace SignToolGUI.Class
99
{
1010
public class CertificateMonitor
1111
{
12+
private readonly int _warningThresholdDays;
13+
private readonly int _criticalThresholdDays;
14+
1215
public enum AlertLevel
1316
{
1417
None,
@@ -24,10 +27,7 @@ public class CertificateAlert
2427
public int DaysUntilExpiry { get; set; }
2528
public string Message { get; set; }
2629
public string CertificateName { get; set; }
27-
}
28-
29-
private readonly int _warningThresholdDays;
30-
private readonly int _criticalThresholdDays;
30+
}
3131

3232
public CertificateMonitor(int warningThresholdDays = 90, int criticalThresholdDays = 30)
3333
{

src/SignToolGUI/Class/FileLogger.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ internal class FileLogger
2727
// Get logfile path
2828
public static string GetLogPath(string df)
2929
{
30-
return Files.LogFilePath + @"\" + Globals.ToolName.SignToolGui + " Log " + df + ".log";
30+
return FileManager.LogFilePath + @"\" + Globals.ToolName.SignToolGui + " Log " + df + ".log";
3131
}
3232

3333
// Get datetime
@@ -77,9 +77,9 @@ private static void AppendMessageToFile(string mess, EventType type, string dtf,
7777
// Check if file exists else create it
7878
try
7979
{
80-
if (!Directory.Exists(Files.LogFilePath))
80+
if (!Directory.Exists(FileManager.LogFilePath))
8181
{
82-
Directory.CreateDirectory(Files.LogFilePath);
82+
Directory.CreateDirectory(FileManager.LogFilePath);
8383
//Console.WriteLine("Directory to log files created: " + Files.LogFilePath);
8484
}
8585
}
@@ -97,7 +97,7 @@ private static void AppendMessageToFile(string mess, EventType type, string dtf,
9797
}
9898

9999
// Check if we have write access to the directory
100-
if (!HasWriteAccessToDirectory(Files.LogFilePath))
100+
if (!HasWriteAccessToDirectory(FileManager.LogFilePath))
101101
{
102102
if (WriteToEventLog)
103103
{
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace SignToolGUI.Class
44
{
5-
class Files
5+
class FileManager
66
{
77
public static string ConfigIniPath
88
{

src/SignToolGUI/Class/Globals.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ internal class ToolStates
3232
internal static string MichaelCodeSignThumbprintOffline = "D6A630B8F65C473C19F8B694491130073FCCDB32";
3333
}
3434

35+
internal class ToolStings
36+
{
37+
internal static string URLAzurePortalTrustedSigning = @"https://portal.azure.com/#browse/Microsoft.CodeSigning%2Fcodesigningaccounts";
38+
}
39+
40+
3541
internal static async Task<string> FetchCurrentCertificateThumbprintAsync()
3642
{
3743
const string url = "https://raw.githubusercontent.com/michaelmsonne/michaelmsonne/main/Trusted_Publisher_Certificate/CurrentCertificateThumbprint.txt";
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using System.Diagnostics;
2+
using static SignToolGUI.Class.FileLogger;
3+
4+
namespace SignToolGUI.Class
5+
{
6+
public class SigningValidator
7+
{
8+
public static string GetSigningTimestampFromFile(string filePath, string signToolExe)
9+
{
10+
var psi = new ProcessStartInfo
11+
{
12+
FileName = signToolExe,
13+
Arguments = $"verify /v /all \"{filePath}\"",
14+
RedirectStandardOutput = true,
15+
UseShellExecute = false,
16+
CreateNoWindow = true
17+
};
18+
using (var process = Process.Start(psi))
19+
{
20+
string output = process.StandardOutput.ReadToEnd();
21+
process.WaitForExit();
22+
23+
// Try to match several possible timestamp lines
24+
var match1 = System.Text.RegularExpressions.Regex.Match(output, @"Timestamp:\s*(.+)");
25+
if (match1.Success)
26+
return match1.Groups[1].Value.Trim();
27+
28+
var match2 = System.Text.RegularExpressions.Regex.Match(output, @"Signed Time:\s*(.+)");
29+
if (match2.Success)
30+
return match2.Groups[1].Value.Trim();
31+
32+
var match3 = System.Text.RegularExpressions.Regex.Match(output, @"The signature is timestamped:\s*(.+)");
33+
if (match3.Success)
34+
return match3.Groups[1].Value.Trim();
35+
36+
// Optionally, log the output for debugging
37+
Message("SignTool verify output for timestamp: " + output, EventType.Error, 9999);
38+
39+
return "N/A";
40+
}
41+
}
42+
}
43+
}

0 commit comments

Comments
 (0)