public static void FirmaDocumentoAnulacion() { var documento = FirmaDocumento.FirmarDocumentoAnulacion("C:\\temp\\Firma\\50510231.p12", "Prueba123", @"C:\Users\lflorian\Documents\ONIX\Documentos\FESP-Anulacion.xml", @"C:\Users\lflorian\Documents\ONIX\Documentos"); if (documento != null) { Console.WriteLine("Documento firmado correctamente"); } else { Console.WriteLine("No se pudo firmar el documento"); } }
static void Main(string[] args) { var documento = FirmaDocumento.FirmarDocumento("C:\\temp\\Firma\\50510231.p12", "Prueba123", "C:\\temp\\Firma\\Documento.xml", "C:\\temp\\Firma"); if (documento != null) { Console.WriteLine("Documento firmado correctamente"); } else { Console.WriteLine("No se pudo firmar el documento"); } Console.ReadKey(); }
static void Main(string[] args) { Console.WriteLine("Ingresa la ruta del documento a firmar"); //var ruta = Console.ReadLine(); var ruta = @"C:\temp\Firma\Documento-Firmado.xml"; XmlDocument xdoc = new XmlDocument(); var doc = File.ReadAllText(ruta); bool resultado = FirmaDocumento.ValidarDocumento(doc, "C:\\temp\\Firma\\50510231.p12", "Prueba123"); if (resultado) { Console.WriteLine("Documento valido"); } else { Console.WriteLine("Documento invalido"); } Console.ReadKey(); }
public String getXML(string XMLInvoice, string XMLDetailInvoce, string path, string fac_num) { v_rootxml = path; this.fac_num = fac_num; //convertir a dataset los string para mayor manupulacion XmlToDataSet(XMLInvoice, XMLDetailInvoce); //llenar estructuras ReaderDataset(); //armar xml getXML(); //firmar xml por certificado var nombre = fac_num.Trim() + ".xml"; v_rootxml = v_rootxml + @"\" + nombre; XmlDocument myXML = FirmaDocumento.FirmarDocumento(Constants.URL_CERTIFICADO, Constants.URL_CERTIFICADO_CONTRASENIA, path, nombre, path); return(myXML.InnerXml); }
private void btnFirma_Click(object sender, EventArgs e) { if (certificatePath == "" || certificatePath == null) { MessageBox.Show("Se debe seleccionar el certifiado para realizar la firma"); return; } if (txtContraseña.Text == "" || txtContraseña.Text == null) { MessageBox.Show("Se debe ingresar la contraseña del certificado"); return; } if (filePath == "" || filePath == null) { MessageBox.Show("Se debe seleccionar un archivo xml para firmar"); return; } var destinationPath = Path.GetDirectoryName(filePath); var fileName = Path.GetFileNameWithoutExtension(filePath); try { FirmaDocumento.FirmarDocumento(certificatePath, txtContraseña.Text, filePath, destinationPath); } catch (Exception es) { lblMensae.Text = $"Error en la firma del documento, error reportado: {es.Message}"; lblMensae.ForeColor = Color.Red; return; } lblMensae.Text = $"Documento Firmado correctamente, ubicado en: {Path.Combine(destinationPath, fileName)}-Firmado.xml"; lblMensae.ForeColor = Color.Green; }
private void btnFirma_Click(object sender, EventArgs e) { documentos.ToList().ForEach(d => { FirmaDocumento.FirmarDocumento("C:\\temp\\Firma\\50510231.p12", "Prueba123", d, "C:\\temp\\Firma"); }); }