예제 #1
0
        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");
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
            }
        }
예제 #4
0
        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);
            }
        }