private void bVerify_Click(object sender, EventArgs e) { UpdatePackageInfo desc; string hashbase64; AppendLog("Verifying Signature"); eVerDescriptionFile.Text = dlgSelectUpdateDescFile.FileName; try { desc = UpdatePackageInfo.FromFile(dlgSelectUpdateDescFile.FileName, _PrivateKey.ToXmlString(false)); if (desc != null) { AppendLog("OK - xml signature is ok"); iXmlSignature.Text = "Xml signature is OK"; iXmlSignature.ImageIndex = 10; } else { AppendLog("ERROR - xml signature missmatch"); iXmlSignature.Text = "Xml signature is NOT OK"; iXmlSignature.ImageIndex = 11; iUpdateFileSignature.Text = "Not tested"; iUpdateFileSignature.ImageIndex = 9; return; } if (!UpdatePackageInfoHelper.CreateSHA512HashForFile(eVerUpdateFile.Text, out hashbase64)) { AppendLog("Could not create hash for updatefile - only verifying xml!"); iUpdateFileSignature.Text = "Cannot be tested (file error)"; iUpdateFileSignature.ImageIndex = 9; } else { if (desc.UpdateFileSignature == hashbase64) { AppendLog("Hash is OK"); iUpdateFileSignature.Text = "Update file signatures match"; iUpdateFileSignature.ImageIndex = 10; } else { AppendLog("Hash is NOT OK"); iUpdateFileSignature.Text = "Update file signatures DO NOT match"; iUpdateFileSignature.ImageIndex = 11; } } } catch { AppendLog("Error verifying signature"); } }
private void iOpen_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (dlgSelectUpdateDescFile.ShowDialog() == System.Windows.Forms.DialogResult.OK) { eVerDescriptionFile.Text = dlgSelectUpdateDescFile.FileName; UpdatePackageInfo desc = UpdatePackageInfo.FromFile(dlgSelectUpdateDescFile.FileName); if (desc != null) { eTitle.Text = desc.Title; eDescription.Text = desc.Description; eReleaseLink.Text = desc.ReleaseNotesUri; ePublishDate.EditValue = desc.PublishDate; eNewVersion.Text = desc.Version; eUpdateFile.Text = ""; } } }