Neispravan Digitalni potpis

Nov 18, 2013 at 8:43 AM
Bok

Mi smo u razvoju našeg softvera fiszalizaciju i mi koristiti C # so Visual Studio 2010; webservice uvijek reagira s porukom "Neispravan Digitalni potpis". Mi smo testirali različite metode, s trenutnom koda smo pretvoriti Racunzahtev u dokumentu XML pomoću Serialize, provodimo generacije potpis i opet mi smo pretvoriti u objekt Racunzahtev prije nego objavi u webservice. Ne mogli smo obavljati generaciju potpis bez ove pretvorbe u XML dokumentu.

Također smo pokušali da neće koristiti objekt Racunzahtev i stvoriti stvaranje XML dokument s potrebnom formatu, ali dobili isti rezultat ("Neispravan Digitalni potpis").

Ne znam kako da se krene naprijed.

Mnogo hvala.
X509Certificate2 cert = new X509Certificate2("fiskal1.pfx", "xxxxxx",X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet);
X509Store store = new X509Store(StoreName.My, StoreLocation.LocalMachine);
store.Open(OpenFlags.ReadWrite);
store.Add(cert);
RSACryptoServiceProvider provider = (RSACryptoServiceProvider)cert.PrivateKey;
XmlSerializer serializador = new XmlSerializer(typeof(RacunZahtjev));
TextWriter writer = new StreamWriter("prueba.xml");
serializador.Serialize(writer, vXML);
writer.Close();
XmlDocument doc = new XmlDocument();
doc.PreserveWhitespace = true;
doc.Load("prueba.xml");
SignedXml XmlFirmado = new SignedXml(doc);
XmlFirmado.SigningKey = provider;
XmlFirmado.SignedInfo.CanonicalizationMethod = SignedXml.XmlDsigExcC14NTransformUrl;

KeyInfo keyinfo = new KeyInfo();
KeyInfoX509Data keyinfodata = new KeyInfoX509Data();
keyinfodata.AddCertificate(cert);
keyinfodata.AddIssuerSerial(cert.Issuer, cert.GetSerialNumberString());
keyinfo.AddClause(keyinfodata);

XmlFirmado.KeyInfo = keyinfo;

Reference ref1 = new Reference("");
ref1.AddTransform(new XmlDsigEnvelopedSignatureTransform(false));
ref1.AddTransform(new XmlDsigExcC14NTransform(false));
ref1.Uri = "#racunId";
XmlFirmado.AddReference(ref1);
XmlFirmado.ComputeSignature();

XmlElement elemento = XmlFirmado.GetXml();
doc.DocumentElement.AppendChild(elemento);
XmlTextWriter xmltw = new XmlTextWriter("S_prueba.xml", new UTF8Encoding(true));
doc.WriteTo(xmltw);
xmltw.Close();
StreamReader Rser = new StreamReader("S_prueba.xml",new UTF8Encoding(true));
vXML = (RacunZahtjev)serializador.Deserialize(Rser);