Skip to content

Commit 6d66acd

Browse files
committed
Update MainForm.cs
1 parent e45ba06 commit 6d66acd

1 file changed

Lines changed: 47 additions & 1 deletion

File tree

SignToolGUI/Forms/MainForm.cs

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1525,6 +1525,10 @@ private bool VerifyConfiguration()
15251525
if (comboBoxCertificatesInStore.SelectedIndex == 0)
15261526
{
15271527
MessageBox.Show(@"Select a digital certificate from Windows Certificate Store.", @"Select a Certificate", MessageBoxButtons.OK, MessageBoxIcon.Error);
1528+
1529+
// Log the error message for no certificate selected
1530+
Message("No digital certificate selected from Windows Certificate Store", EventType.Error, 1055);
1531+
15281532
return false; // Indicate failure
15291533
}
15301534
if (!_signingCerts[comboBoxCertificatesInStore.SelectedIndex - 1].HasPrivateKey)
@@ -1535,13 +1539,21 @@ private bool VerifyConfiguration()
15351539
15361540
Select another digital certificate.",
15371541
Globals.MsgBox.Error, MessageBoxButtons.OK, MessageBoxIcon.Hand);
1542+
1543+
// Log the error message for no private key found in the selected certificate
1544+
Message("No private key found in the selected certificate from Windows Certificate Store", EventType.Error, 1056);
1545+
15381546
return false; // Indicate failure
15391547
}
15401548
}
15411549

15421550
if (string.IsNullOrEmpty(txtTimestampProviderURL.Text))
15431551
{
15441552
MessageBox.Show(@"Please enter the URL of the timestamp provider.", @"SignTool GUI", MessageBoxButtons.OK, MessageBoxIcon.Error);
1553+
1554+
// Log the error message for no timestamp provider URL entered
1555+
Message("No timestamp provider URL entered", EventType.Error, 1057);
1556+
15451557
return false; // Indicate failure
15461558
}
15471559

@@ -1552,18 +1564,30 @@ private bool VerifyConfiguration()
15521564
MessageBox.Show(@"No .pfx/.p12 file selected.
15531565
Please provide a valid file to use for signing!
15541566
Use the ... button above and select the code signing certificate to use!", @"No .pfx/.p12 file selected", MessageBoxButtons.OK, MessageBoxIcon.Question);
1567+
1568+
// Log the error message for no .pfx/.p12 file selected
1569+
Message("No .pfx/.p12 file selected", EventType.Error, 1058);
1570+
15551571
return false; // Indicate failure
15561572
}
15571573

15581574
if (!File.Exists(textBoxPFXFile.Text))
15591575
{
15601576
MessageBox.Show(@"The specified .pfx/.p12 file does not exist or access to it failed.", @"Selected file or path does not exist", MessageBoxButtons.OK, MessageBoxIcon.Error);
1577+
1578+
// Log the error message for the .pfx/.p12 file not found or access failed
1579+
Message("The specified .pfx/.p12 file does not exist or access to it failed", EventType.Error, 1059);
1580+
15611581
return false; // Indicate failure
15621582
}
15631583

15641584
if (string.IsNullOrEmpty(textBoxPFXPassword.Text))
15651585
{
15661586
MessageBox.Show(@".pfx/.p12 password cannot be empty.", @"Missing password", MessageBoxButtons.OK, MessageBoxIcon.Question);
1587+
1588+
// Log the error message for the .pfx/.p12 password being empty
1589+
Message(".pfx/.p12 password cannot be empty", EventType.Error, 1060);
1590+
15671591
return false; // Indicate failure
15681592
}
15691593

@@ -1572,13 +1596,23 @@ private bool VerifyConfiguration()
15721596
if (!new X509Certificate2(File.ReadAllBytes(textBoxPFXFile.Text), textBoxPFXPassword.Text).HasPrivateKey)
15731597
{
15741598
MessageBox.Show(@"Error obtaining the private key from the .pfx/.p12 file. The certificate cannot be used to create digital signatures.", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
1599+
1600+
// Log the error message for the private key not found in the .pfx/.p12 file
1601+
Message("Error obtaining the private key from the .pfx/.p12 file. The certificate cannot be used to create digital signatures.", EventType.Error, 1061);
1602+
15751603
return false; // Indicate failure
15761604
}
15771605
}
15781606
catch
15791607
{
15801608
MessageBox.Show(@"Error obtaining the certificate from the .pfx/.p12 file. Probably .pfx/.p12 password is not correct or the .pfx/.p12 file is invalid.", "", MessageBoxButtons.OK, MessageBoxIcon.Hand);
1609+
1610+
// Log the error message for the certificate not found in the .pfx/.p12 file or the password being incorrect
1611+
Message("Error obtaining the certificate from the .pfx/.p12 file. Probably .pfx/.p12 password is not correct or the .pfx/.p12 file is invalid.", EventType.Error, 1062);
1612+
1613+
// Clear the certificate data and show an error message
15811614
labelCertificateInformation.Text = Globals.DigitalCertificates.CertificateInfoIsNotAvailable;
1615+
15821616
return false; // Indicate failure
15831617
}
15841618
}
@@ -1587,6 +1621,10 @@ private bool VerifyConfiguration()
15871621
{
15881622
// Show an error message
15891623
MessageBox.Show(exception.ToString(), @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
1624+
1625+
// Log the error message
1626+
Message("Error verifying the configuration: " + exception.Message, EventType.Error, 1063);
1627+
15901628
return false; // Indicate failure
15911629
}
15921630

@@ -1614,17 +1652,25 @@ private void linkLabelOpenTrustedSigningPortal_LinkClicked(object sender, LinkLa
16141652

16151653
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
16161654
{
1655+
// Log the user's action to open the About form
1656+
Message("User clicked the 'About' menu item to open the About form", EventType.Information, 1056);
1657+
1658+
// Open the About form
16171659
AboutForm f2 = new AboutForm();
16181660
f2.ShowDialog();
16191661
}
16201662

16211663
private void changelogToolStripMenuItem_Click(object sender, EventArgs e)
16221664
{
1665+
// Log the user's action to open the Changelog form
1666+
Message("User clicked the 'Changelog' menu item to open the Changelog form", EventType.Information, 1057);
1667+
1668+
// Open the Changelog form
16231669
ChangelogForm f2 = new ChangelogForm();
16241670
f2.ShowDialog();
16251671
}
16261672

1627-
#endregion Form actions
1673+
#endregion Form actions
16281674

16291675
#region Sign options - GUI
16301676

0 commit comments

Comments
 (0)