private void btnCadesT_Click(object sender, EventArgs e) { if (_signatureDocument == null) { return; } FrmSeleccionarFirma frm = new FrmSeleccionarFirma(_signatureDocument); if (frm.ShowDialog() != System.Windows.Forms.DialogResult.OK) { MessageBox.Show("You must select a signature"); return; } UpgradeParameters up = new UpgradeParameters(); up.TsaClient = new TimeStampClient(txtURLSellado.Text); up.DigestMethod = DigestMethod.SHA256; CadesTUpgrader upgrader = new CadesTUpgrader(); upgrader.Upgrade(_signatureDocument, frm.SignerInfo, up); MessageBox.Show("Signature extended successfully"); }
private void btnContraFirma_Click(object sender, EventArgs e) { if (_signatureDocument == null) { return; } FrmSeleccionarFirma frm = new FrmSeleccionarFirma(_signatureDocument); if (frm.ShowDialog() != System.Windows.Forms.DialogResult.OK) { MessageBox.Show("Debe seleccionar una firma"); return; } SignatureParameters parametros = ObtenerParametrosFirma(); parametros.SignaturePolicyInfo = null; parametros.Certificate = CertUtil.SelectCertificate(); using (parametros.Signer = new Signer((X509Certificate2)parametros.Certificate)) { CadesService cs = new CadesService(); _signatureDocument = cs.CounterSign(_signatureDocument, frm.SignerInfo, parametros); } MessageBox.Show("Signature completed, you can now save the signature or extend it to CAdES-T.", "CAdES signature test", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void btnValidar_Click(object sender, EventArgs e) { if (_signatureDocument == null) { return; } FrmSeleccionarFirma frm = new FrmSeleccionarFirma(_signatureDocument); if (frm.ShowDialog() != System.Windows.Forms.DialogResult.OK) { MessageBox.Show("You must select a signature"); return; } CadesValidator cv = new CadesValidator(); var result = cv.Validate(_signatureDocument, frm.SignerInfo); if (result.IsValid) { MessageBox.Show("Signature is valid"); } else { MessageBox.Show("Verification failed: " + result.Message); } }
private void btnValidar_Click(object sender, EventArgs e) { if (_signatureDocument == null) { return; } FrmSeleccionarFirma frm = new FrmSeleccionarFirma(_signatureDocument); if (frm.ShowDialog() != System.Windows.Forms.DialogResult.OK) { MessageBox.Show("Debe seleccionar una firma"); return; } CadesValidator cv = new CadesValidator(); var result = cv.Validate(_signatureDocument, frm.SignerInfo); if (result.IsValid) { MessageBox.Show("Firma válida"); } else { MessageBox.Show("La verificación no ha sido satisfactoria: " + result.Message); } }