private void Client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e) { progressDownload.Visible = false; btnInstallAndReLaunch.Visible = true; // report message _sparkle.ReportDiagnosticMessage("Finished downloading file to: " + _tempName); // check if we have a dsa signature in appcast if (_item.DSASignature == null || _item.DSASignature.Length == 0) { _sparkle.ReportDiagnosticMessage("No DSA check needed"); } else { Boolean bDSAOk = false; // report _sparkle.ReportDiagnosticMessage("Performing DSA check"); // get the assembly if (File.Exists(_tempName)) { // check if the file was downloaded successfully String absolutePath = Path.GetFullPath(_tempName); if (!File.Exists(absolutePath)) { throw new FileNotFoundException(); } // get the assembly reference from which we start the update progress // only from this trusted assembly the public key can be used Assembly refassembly = Assembly.GetEntryAssembly(); if (refassembly != null) { // Check if we found the public key in our entry assembly if (NetSparkleDSAVerificator.ExistsPublicKey(refassembly.GetName().Name + ".NetSparkle_DSA.pub")) { // check the DSA Code and modify the back color NetSparkleDSAVerificator dsaVerifier = new NetSparkleDSAVerificator(refassembly.GetName().Name + ".NetSparkle_DSA.pub"); bDSAOk = dsaVerifier.VerifyDSASignature(_item.DSASignature, _tempName); } } } if (!bDSAOk) { Size = new Size(Size.Width, 137); lblSecurityHint.Visible = true; BackColor = Color.Tomato; } } // Check the unattended mode if (_unattend) { btnInstallAndReLaunch_Click(null, null); } }
/// <summary> /// Event called when the download of the binary is complete /// </summary> /// <param name="sender">not used.</param> /// <param name="e">not used.</param> public void OnClientDownloadFileCompleted(object sender, AsyncCompletedEventArgs e) { if (e.Cancelled || e.Error != null) { return; } progressDownload.Visible = false; btnInstallAndReLaunch.Visible = true; // this should move to Sparkle itself. // report message _sparkle.ReportDiagnosticMessage("Finished downloading file to: " + _tempName); // check if we have a dsa signature in appcast if (string.IsNullOrEmpty(_item.DSASignature)) { _sparkle.ReportDiagnosticMessage("No DSA check needed"); } else { this.IsDownloadDSAValid = false; // report _sparkle.ReportDiagnosticMessage("Performing DSA check"); // get the assembly if (File.Exists(_tempName)) { // check if the file was downloaded successfully String absolutePath = Path.GetFullPath(_tempName); if (!File.Exists(absolutePath)) { throw new FileNotFoundException(); } // get the assembly reference from which we start the update progress // only from this trusted assembly the public key can be used Assembly refassembly = Assembly.GetEntryAssembly(); if (refassembly != null) { // Check if we found the public key in our entry assembly if (NetSparkleDSAVerificator.ExistsPublicKey("NetSparkle_DSA.pub")) { // check the DSA Code and modify the back color NetSparkleDSAVerificator dsaVerifier = new NetSparkleDSAVerificator("NetSparkle_DSA.pub"); this.IsDownloadDSAValid = dsaVerifier.VerifyDSASignature(_item.DSASignature, _tempName); } } } UpdateDownloadValid(); } // Check the unattended mode if (_unattend) { OnInstallAndReLaunchClick(null, null); } }
/// <summary> /// Called when the installer is downloaded /// </summary> /// <param name="sender">not used.</param> /// <param name="e">used to determine if the download was successful.</param> void OnWebDownloadClientDownloadFileCompleted(object sender, AsyncCompletedEventArgs e) { if (!e.Cancelled && e.Error == null) { // test the item for DSA signature bool isDSAOk = false; // report ReportDiagnosticMessage("Performing DSA check"); // get the assembly if (File.Exists(_downloadTempFileName)) { // check if the file was downloaded successfully String absolutePath = Path.GetFullPath(_downloadTempFileName); if (!File.Exists(absolutePath)) { throw new FileNotFoundException(); } // get the assembly reference from which we start the update progress // only from this trusted assembly the public key can be used Assembly refassembly = System.Reflection.Assembly.GetEntryAssembly(); if (refassembly != null) { // Check if we found the public key in our entry assembly if (NetSparkleDSAVerificator.ExistsPublicKey("NetSparkle_DSA.pub")) { // check the DSA Code and modify the back color NetSparkleDSAVerificator dsaVerifier = new NetSparkleDSAVerificator("NetSparkle_DSA.pub"); isDSAOk = dsaVerifier.VerifyDSASignature(this.UserWindow.CurrentItem.DSASignature, _downloadTempFileName); } } } if (this.ProgressWindow != null) { this.ProgressWindow.IsDownloadDSAValid = isDSAOk; } } if (this.ProgressWindow != null) { this.ProgressWindow.OnClientDownloadFileCompleted(sender, e); } }
public static bool CheckDSA(Sparkle sparkle, NetSparkleAppCastItem item, String tempName) { Boolean bDSAOk = false; // check if we have a dsa signature in appcast if (item.DSASignature == null || item.DSASignature.Length == 0) { sparkle.ReportDiagnosticMessage("No DSA check needed"); bDSAOk = true; } else { // report sparkle.ReportDiagnosticMessage("Performing DSA check"); // get the assembly if (File.Exists(tempName)) { // check if the file was downloaded successfully String absolutePath = Path.GetFullPath(tempName); if (!File.Exists(absolutePath)) { throw new FileNotFoundException(); } // get the assembly reference from which we start the update progress // only from this trusted assembly the public key can be used Assembly refassembly = System.Reflection.Assembly.GetEntryAssembly(); if (refassembly != null) { // Check if we found the public key in our entry assembly if (NetSparkleDSAVerificator.ExistsPublicKey("NetSparkle_DSA.pub")) { // check the DSA Code and modify the back color NetSparkleDSAVerificator dsaVerifier = new NetSparkleDSAVerificator("NetSparkle_DSA.pub"); bDSAOk = dsaVerifier.VerifyDSASignature(item.DSASignature, tempName); } } } } return(bDSAOk); }