Skip to content

Commit 92fa0e1

Browse files
committed
Update Program.cs
Verify digital signatures of ConvAssist.exe and ACATWatch.exe
1 parent 04fb1a4 commit 92fa0e1

File tree

1 file changed

+38
-14
lines changed

1 file changed

+38
-14
lines changed

src/Applications/ACATTalk/Program.cs

+38-14
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
//
1212
////////////////////////////////////////////////////////////////////////////
1313

14-
#define ONBOARDING
1514
//#define ENABLE_DIGITAL_VERIFICATION
1615

1716
using ACAT.ACATResources;
@@ -54,7 +53,7 @@ public static void Main(String[] args)
5453
Application.EnableVisualStyles();
5554
Application.SetCompatibleTextRenderingDefault(false);
5655

57-
if (!validateACATCoreLibraryCertificates())
56+
if (!validateACATCoreLibraryCertificates() || !validateConvAssistCertificate() || !validateACATWatchCertificate())
5857
{
5958
MessageBox.Show("Please reinstall ACAT and retry", "ACAT", MessageBoxButtons.OK, MessageBoxIcon.Information);
6059
return;
@@ -110,21 +109,12 @@ public static void Main(String[] args)
110109

111110
Common.AppPreferences.PreferredPanelConfigNames = String.Empty;
112111

113-
// to enable onboarding, uncomment the #define ONBOARDING at the top of the file
114-
// to enable BCI, comment out the #define ONBOARDING statement and uncomment #define BCI
115-
#if ONBOARDING
116112

117113
if (!doOnboarding())
118114
{
119115
return;
120116
}
121117

122-
#elif BCI
123-
Common.AppPreferences.PreferredPanelConfigNames = "TalkApplicationBCIScannerABC";
124-
#else
125-
Common.AppPreferences.PreferredPanelConfigNames = "TalkApplicationAbc";
126-
#endif
127-
128118
Splash splash = new Splash(2000);
129119
splash.Show();
130120

@@ -289,16 +279,50 @@ private static bool validateACATCoreLibraryCertificates()
289279
#endif
290280
}
291281

282+
private static bool validateConvAssistCertificate()
283+
{
284+
#if ENABLE_DIGITAL_VERIFICATION
285+
286+
var appPath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
287+
var convAssistPath = Path.Combine(appPath, "ConvAssistApp", "ConvAssist.exe");
288+
if (!validateCertificate(convAssistPath))
289+
{
290+
return false;
291+
}
292+
293+
return true;
294+
#else
295+
return true;
296+
#endif
297+
}
298+
299+
private static bool validateACATWatchCertificate()
300+
{
301+
#if ENABLE_DIGITAL_VERIFICATION
302+
303+
var appPath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
304+
var acatWatchPath = Path.Combine(appPath, "ACATWatch.exe");
305+
if (!validateCertificate(acatWatchPath))
306+
{
307+
return false;
308+
}
309+
310+
return true;
311+
#else
312+
return true;
313+
#endif
314+
}
315+
292316
#if ENABLE_DIGITAL_VERIFICATION
293-
private static bool validateCertificate(String dllPath)
317+
private static bool validateCertificate(String filePath)
294318
{
295319
try
296320
{
297-
Verify(dllPath);
321+
Verify(filePath);
298322
}
299323
catch (Exception ex)
300324
{
301-
MessageBox.Show("Digital signature verification failed for the following DLL.\n\n" + dllPath + "\n\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
325+
MessageBox.Show("Digital signature verification failed for the following file.\n\n" + filePath + "\n\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
302326
return false;
303327
}
304328

0 commit comments

Comments
 (0)