private void AmpliarFirma(SignatureFormat formato)
        {
            try
            {
                UpgradeParameters parametros = new UpgradeParameters();

                parametros.TimeStampClient = new TimeStampClient(txtURLSellado.Text);
                parametros.OCSPServers.Add(new OcspServer(txtOCSP.Text));

                // test con @firma

                /* parametros.GetOcspUrlFromCertificate = false;
                 * OcspServer ocspServer = new OcspServer("https://afirma.redsara.es/servidorOcsp/servidorOCSP");
                 * ocspServer.SetRequestorName(OcspServer.Rfc822Name, "idAplicacion");
                 * ocspServer.SignCertificate = CertUtil.SelectCertificate();
                 *
                 * parametros.OCSPServers.Add(ocspServer); */

                XadesUpgraderService upgrader = new XadesUpgraderService();
                upgrader.Upgrade(_signatureDocument, formato, parametros);

                MessageBox.Show("Firma ampliada correctamente", "Test firma XADES",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ha ocurrido un error ampliando la firma: " + ex.Message);
            }
        }
Beispiel #2
0
        string SignDocument(X509Certificate2 signCertificate, System.IO.Stream inputStream, SignatureProductionPlace signatureProductionPlace, string timeStampUrl = "https://freetsa.org/tsr", SignatureFormat format = SignatureFormat.XAdES_T)
        {
            FirmaXadesNet.XadesService svc = new FirmaXadesNet.XadesService();

            var parameters = new SignatureParameters()
            {
                SignatureMethod          = SignatureMethod.RSAwithSHA256,
                SigningDate              = DateTime.Now,
                SignaturePackaging       = SignaturePackaging.ENVELOPED,
                InputMimeType            = "text/xml",
                SignatureProductionPlace = signatureProductionPlace
            };

            parameters.SignatureCommitments.Add(new SignatureCommitment(SignatureCommitmentType.ProofOfOrigin));

            using (parameters.Signer = new Signer(signCertificate))
            {
                var signedDocument = svc.Sign(inputStream, parameters);
                signedDocument.Document.PreserveWhitespace = true;
                UpgradeParameters xadesTparameters = new UpgradeParameters()
                {
                    TimeStampClient = new TimeStampClient(timeStampUrl)
                };
                if (format == SignatureFormat.XAdES_XL)
                {
                    xadesTparameters.OCSPServers.Add(new OcspServer("http://srvdc06.crossroad.ltd/ocsp"));
                }
                XadesUpgraderService upgrader = new XadesUpgraderService();
                upgrader.Upgrade(signedDocument, format, xadesTparameters);

                return(signedDocument.Document.OuterXml);
            }
        }
Beispiel #3
0
        private void AmpliarFirma(SignatureFormat formato)
        {
            try
            {
                UpgradeParameters parametros = new UpgradeParameters();

                parametros.TimeStampClient = new TimeStampClient(txtURLSellado.Text);
                parametros.OCSPServers.Add(txtOCSP.Text);

                XadesUpgraderService upgrader = new XadesUpgraderService();
                upgrader.Upgrade(_signatureDocument, formato, parametros);

                MessageBox.Show("Firma ampliada correctamente", "Test firma XADES",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ha ocurrido un error ampliando la firma: " + ex.Message);
            }
        }
Beispiel #4
0
        private void AmpliarFirma(SignatureFormat formato)
        {
            try
            {
                UpgradeParameters parametros = new UpgradeParameters
                {
                    TimeStampClient = new TimeStampClient(txtURLSellado.Text)
                };
                parametros.OCSPServers.Add(new OcspServer(txtOCSP.Text));

                XadesUpgraderService upgrader = new XadesUpgraderService();
                upgrader.Upgrade(_signatureDocument, formato, parametros);

                MessageBox.Show("Signature extended correctly", $"Extend to {formato.ToString()}",
                                MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error has occurred extending the signature: " + ex.Message);
            }
        }