Login Registre-se
setar uri na assinatura da NFe  XML
Índice dos Fóruns » NF-e / NFS-e / CT-e / CF-e / Certificados Digitais
Autor Mensagem
celma.costa

JavaC Membro
[Avatar]

Membro desde: 29/11/2016 13:54:48
Mensagens: 9
Localização: Barueri SP
Offline

Estou conseguindo assinar um xml da NFe usando o código disponibilizado pelo Maciel em 2011:
http://www.javac.com.br/jc/posts/list/106-nfe-assinatura-dos-xmls-de-envio-de-lote-cancelamento-e-inutilizacao-certificado-a1.page

Mas se eu seto o uri o arquivo não é gerado.
Reference ref = fac.newReference("#" + id,
fac.newDigestMethod(DigestMethod.SHA1, null), transformList,
null, null);

Só consigo gerar o arquivo assinado se deixo o uri em branco.

Reference ref = fac.newReference("",
fac.newDigestMethod(DigestMethod.SHA1, null), transformList,
null, null);

Adicionei este exception no final da função assinarNFe para tentar ver o erro, mas o arquivo continua não sendo gerado.
catch (Exception e) {

Element book = document.createElement("error");
book.setAttribute("id", e.getMessage());
document.appendChild(book);
}

Não consigo debugar a rotina pq meu sistema chama as rotinas java 'encapsuladamente'. Instalei o eclipse e tentei criar um projeto java para testar só a rotina java, mas como não conheço a ferramenta estou me batendo nisso tb.
Por favor, se alguém puder me ajudar... estou empacada nisso já fazem alguns dias.
robertop

JavaC Membro

Membro desde: 10/07/2013 20:08:36
Mensagens: 163
Offline

Olá Celma, posta o código completo da sua assinatura.

celma.costa

JavaC Membro
[Avatar]

Membro desde: 29/11/2016 13:54:48
Mensagens: 9
Localização: Barueri SP
Offline

Desde já agradeço pela atenção.

Aí vai:

import ifs.fnd.base.IfsException;
import ifs.fnd.tc.framework.xml.Transformer;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.security.InvalidAlgorithmParameterException;
import java.security.KeyStore;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;
import javax.xml.crypto.dsig.CanonicalizationMethod;
import javax.xml.crypto.dsig.DigestMethod;
import javax.xml.crypto.dsig.Reference;
import javax.xml.crypto.dsig.SignatureMethod;
import javax.xml.crypto.dsig.SignedInfo;
import javax.xml.crypto.dsig.Transform;
import javax.xml.crypto.dsig.XMLSignature;
import javax.xml.crypto.dsig.XMLSignatureFactory;
import javax.xml.crypto.dsig.keyinfo.KeyInfo;
import javax.xml.crypto.dsig.keyinfo.KeyInfoFactory;
import javax.xml.crypto.dsig.keyinfo.X509Data;
import javax.xml.crypto.dsig.spec.C14NMethodParameterSpec;
import javax.xml.crypto.dsig.spec.TransformParameterSpec;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
import java.io.StringWriter;
import java.io.*;
import java.security.*;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import javax.xml.crypto.dsig.dom.DOMSignContext;
import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.xerces.jaxp.DocumentBuilderFactoryImpl;
import org.w3c.dom.*;
import java.io.IOException;
import org.apache.xml.serialize.OutputFormat;
import org.apache.xml.serialize.XMLSerializer;



public class FisnotSign implements Transformer {
private static String NFE = "NFe";
private PrivateKey privateKey;
private KeyInfo keyInfo;

@Override
public void init() throws IfsException {
}

@Override
public String transform(String sIn) throws IfsException {

String flatText = new String(sIn);
String keyStorePath = new String("D:\\cadeia_certificacao_SEF_MG\\lala.pfx");
String passWord = new String("1234");
String nameNodeToSign = new String("NFe");
try {
String outXml = FisnotSign.digitalSignature(flatText, keyStorePath, passWord, nameNodeToSign);
return (outXml);
} catch (final Exception e) {

// TODO Auto-generated catch block
throw new RuntimeException("Error signing SAML element: "
+ e.getMessage(), e); }
}

public static String digitalSignature(String xmlin, String keyStorePath, String passWord, String nameNodeToSign ) throws Exception {

// final String providerName = System.getProperty("jsr105Provider", JSR_105_PROVIDER);

try {
String caminhoDoCertificadoDoCliente = keyStorePath;
String senhaDoCertificadoDoCliente = passWord;
FisnotSign assinarXMLsCertfificadoA1 = new FisnotSign();
NFE = nameNodeToSign;

String xmlEnviNFe = xmlin;
String xmlEnviNFeAssinado = assinarXMLsCertfificadoA1.assinaEnviNFe(
xmlEnviNFe, caminhoDoCertificadoDoCliente, senhaDoCertificadoDoCliente);

return xmlEnviNFeAssinado;

} catch (final Exception e) {

// TODO Auto-generated catch block
throw new RuntimeException("Error signing SAML element: "
+ e.getMessage(), e); }
}

public String assinaEnviNFe(String xml, String certificado, String senha)
throws Exception {
Document document = documentFactory(xml);


String providerName = System.getProperty("jsr105Provider", "org.jcp.xml.dsig.internal.dom.XMLDSigRI");

final XMLSignatureFactory signatureFactory = XMLSignatureFactory.getInstance("DOM"); //, (Provider) Class.forName(providerName).newInstance() );
ArrayList<Transform> transformList = signatureFactory(signatureFactory);

loadCertificates(certificado, senha, signatureFactory);

for (int i = 0; i < document.getDocumentElement().getElementsByTagName(NFE).getLength(); i++) {
assinarNFe(signatureFactory, transformList, privateKey, keyInfo, document, i);
}






// no error when building - but xml file is not generated
// add file "com.springsource.nu.xom-1.1.0.jar"; to .transformer file
//nu.xom.Builder parser = new nu.xom.Builder();
//String doc = document.toString();
// nu.xom.Document xomDocument = parser.build(doc, null);
//nu.xom.Document xomDocument = nu.xom.converters.DOMConverter.convert(document);
//String xml1 = xomDocument.toXML();

// xml is empty generated
/*javax.xml.transform.dom.DOMSource domSource = new javax.xml.transform.dom.DOMSource(document);
StringWriter writer = new StringWriter();
javax.xml.transform.stream.StreamResult result = new javax.xml.transform.stream.StreamResult(writer);
javax.xml.transform.TransformerFactory tf = javax.xml.transform.TransformerFactory.newInstance();
javax.xml.transform.Transformer transformer = tf.newTransformer();
transformer.transform(domSource, result);
writer.flush();


String xml1 = writer.toString();
if ((xml1 != null) & (!"".equals(xml1))) {
xml1 = xml1.replaceAll("\\r\\n", "");
xml1 = xml1.replaceAll(" standalone=\"no\"", "");
}

return xml1;*/

// xml is empty generated
/*javax.xml.transform.TransformerFactory tFactory = javax.xml.transform.TransformerFactory.newInstance();
javax.xml.transform.Transformer transformer = tFactory.newTransformer();
javax.xml.transform.dom.DOMSource source = new javax.xml.transform.dom.DOMSource(document);
javax.xml.transform.stream.StreamResult result = new javax.xml.transform.stream.StreamResult(System.out);
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.transform(source, result);

return source.toString();*/

// \o/
javax.xml.transform.Transformer transformer = javax.xml.transform.TransformerFactory.newInstance().newTransformer();
javax.xml.transform.stream.StreamResult result = new javax.xml.transform.stream.StreamResult(new StringWriter());
javax.xml.transform.dom.DOMSource source = new javax.xml.transform.dom.DOMSource(document);
transformer.transform(source, result);
return result.getWriter().toString();



/*javax.xml.transform.Result result = new javax.xml.transform.stream.StreamResult( System.out );
String resultxml = result.toString();
if ((resultxml != null) & (!"".equals(resultxml))) {
resultxml = resultxml.replaceAll("\\r\\n", "");
resultxml = resultxml.replaceAll(" standalone=\"no\"", "");
}*/


/* nu.xom.Document xomDocument =
nu.xom.converters.DOMConverter.convert(document);
String xml1 = xomDocument.toXML();
if ((xml1 != null) & (!"".equals(xml1))) {
xml1 = xml1.replaceAll("\\r\\n", "");
xml1 = xml1.replaceAll(" standalone=\"no\"", "");
}*/


// no error - but no indent
//return getStringFromDoc(document);


/*
// no error - but no indent
//Serialize DOM
OutputFormat format = new OutputFormat ();
format.setLineWidth(120);
format.setIndenting(true);
format.setIndent(2);
format.setEncoding("UTF-8");

// as a String
StringWriter stringOut = new StringWriter ();
XMLSerializer serial = new XMLSerializer (stringOut,
format);
serial.serialize(document);
// Display the XML
//System.out.println(stringOut.toString());


return stringOut.toString();*/
}

// no error - but no indent
private String getStringFromDoc(org.w3c.dom.Document doc) {
org.w3c.dom.ls.DOMImplementationLS domImplementation = (org.w3c.dom.ls.DOMImplementationLS) doc.getImplementation();
org.w3c.dom.ls.LSSerializer lsSerializer = domImplementation.createLSSerializer();
return lsSerializer.writeToString(doc);
}

private Document documentFactory(String xml) throws SAXException,
IOException, ParserConfigurationException {
DocumentBuilderFactory factory = DocumentBuilderFactoryImpl.newInstance();
factory.setNamespaceAware(true);
Document document = factory.newDocumentBuilder().parse(
new ByteArrayInputStream(xml.getBytes()));
return document;
}

private ArrayList<Transform> signatureFactory(
XMLSignatureFactory signatureFactory)
throws NoSuchAlgorithmException, InvalidAlgorithmParameterException {
ArrayList<Transform> transformList = new ArrayList<Transform>();
TransformParameterSpec tps = null;
Transform envelopedTransform = signatureFactory.newTransform(
Transform.ENVELOPED, tps);
Transform c14NTransform = signatureFactory.newTransform(
"http://www.w3.org/TR/2001/REC-xml-c14n-20010315", tps);

transformList.add(envelopedTransform);
transformList.add(c14NTransform);
return transformList;
}

private void loadCertificates(String certificado, String senha,
XMLSignatureFactory signatureFactory) throws Exception {

InputStream entrada = new FileInputStream(certificado);
KeyStore ks = KeyStore.getInstance("pkcs12");
try {
ks.load(entrada, senha.toCharArray());
} catch (IOException e) {
throw new Exception("Senha do Certificado Digital incorreta ou Certificado inválido.");
}

KeyStore.PrivateKeyEntry pkEntry = null;
Enumeration<String> aliasesEnum = ks.aliases();
while (aliasesEnum.hasMoreElements()) {
String alias = (String) aliasesEnum.nextElement();
if (ks.isKeyEntry(alias)) {
pkEntry = (KeyStore.PrivateKeyEntry) ks.getEntry(alias,
new KeyStore.PasswordProtection(senha.toCharArray()));
privateKey = pkEntry.getPrivateKey();
break;
}
}

X509Certificate cert = (X509Certificate) pkEntry.getCertificate();
//info("SubjectDN: " + cert.getSubjectDN().toString());

KeyInfoFactory keyInfoFactory = signatureFactory.getKeyInfoFactory();
List<X509Certificate> x509Content = new ArrayList<X509Certificate>();

x509Content.add(cert);
X509Data x509Data = keyInfoFactory.newX509Data(x509Content);
keyInfo = keyInfoFactory.newKeyInfo(Collections.singletonList(x509Data));
}

private void assinarNFe(XMLSignatureFactory fac,
ArrayList<Transform> transformList, PrivateKey privateKey,
KeyInfo ki, Document document, int indexNFe) throws Exception {

/*Reference ref = fac.newReference("",
fac.newDigestMethod(DigestMethod.SHA1, null), transformList,
null, null);


SignedInfo si = fac.newSignedInfo(fac.newCanonicalizationMethod(
CanonicalizationMethod.INCLUSIVE,
(C14NMethodParameterSpec) null), fac
.newSignatureMethod(SignatureMethod.RSA_SHA1, null),
Collections.singletonList(ref));

XMLSignature signature = fac.newXMLSignature(si, ki);

DOMSignContext dsc = new DOMSignContext(privateKey,
document.getDocumentElement().getElementsByTagName(NFE).item(indexNFe));
signature.sign(dsc);*/

//Sign Whole Document
//NodeList elements1 = (NodeList)document.getDocumentElement();
//Node nodeToSign1 = elements1.item(0);

//org.w3c.dom.Element el1 = (org.w3c.dom.Element) nodeToSign1;;
/*NodeList nodeListToSign = null;


//if (NFE.equals("NFS-e") )
//{
nodeListToSign = document.getElementsByTagName("NFe");
// }


//NodeList nodeListToSign = document.getElementsByTagName("pedidoStatusLote");


Node nodeToSign1 = nodeListToSign.item(0);

Element header = (Element) nodeToSign1;

org.w3c.dom.NodeList elements = document.getElementsByTagName("infNFe");
org.w3c.dom.Element el = (org.w3c.dom.Element) elements.item(indexNFe);
String id = el.getAttribute("Id");

try {
Reference ref1 = fac.newReference("#" + id, /////////////////////////////////////////////////
fac.newDigestMethod(DigestMethod.SHA1, null), transformList,
null, null);





SignedInfo si1 = fac.newSignedInfo(fac.newCanonicalizationMethod(
CanonicalizationMethod.INCLUSIVE, ///////////////////////////////////////////////// INCLUSIVE
(C14NMethodParameterSpec) null), fac
.newSignatureMethod(SignatureMethod.RSA_SHA1, null),
Collections.singletonList(ref1));

XMLSignature signature1 = fac.newXMLSignature(si1, ki);

DOMSignContext dsc1 = new DOMSignContext(privateKey,
document.getDocumentElement().getElementsByTagName(NFE).item(indexNFe)); //header);
signature1.sign(dsc1);
} catch (final Exception e) {

// TODO Auto-generated catch block
throw new RuntimeException("Error signing SAML element: "
+ e.getMessage(), e); }*/


//
try {
NodeList elements = document.getElementsByTagName("infNFe");
org.w3c.dom.Element el = (org.w3c.dom.Element) elements.item(indexNFe);
String id = el.getAttribute("Id");

Reference ref = fac.newReference("#" + id, //
fac.newDigestMethod(DigestMethod.SHA1, null), transformList,
null, null);

SignedInfo si = fac.newSignedInfo(fac.newCanonicalizationMethod(
CanonicalizationMethod.INCLUSIVE,
(C14NMethodParameterSpec) null), fac
.newSignatureMethod(SignatureMethod.RSA_SHA1, null),
Collections.singletonList(ref));

XMLSignature signature = fac.newXMLSignature(si, ki);

DOMSignContext dsc = new DOMSignContext(privateKey,
document.getDocumentElement().getElementsByTagName(NFE).item(indexNFe));
signature.sign(dsc);

} catch (Exception e) {

Element book = document.createElement("error");
book.setAttribute("id", e.getMessage());
document.appendChild(book);

}


//.net

// Create a SignedXml object.
/*SignedXml signedXml = new SignedXml(doc);

// Add the key to the SignedXml document.
signedXml.SigningKey = Key;

// Create a reference to be signed.
Reference reference = new Reference();
reference.Uri = "";

// Add an enveloped transformation to the reference.
XmlDsigEnvelopedSignatureTransform env = new XmlDsigEnvelopedSignatureTransform();
reference.AddTransform(env);

// Add the reference to the SignedXml object.
signedXml.AddReference(reference);


// Add an RSAKeyValue KeyInfo (optional; helps recipient find key to validate).
KeyInfo keyInfo = new KeyInfo();
keyInfo.AddClause(new RSAKeyValue((RSA)Key));
signedXml.KeyInfo = keyInfo;

// Compute the signature.
signedXml.ComputeSignature();

// Get the XML representation of the signature and save
// it to an XmlElement object.
XmlElement xmlDigitalSignature = signedXml.GetXml();

// Append the element to the XML document.
doc.DocumentElement.AppendChild(doc.ImportNode(xmlDigitalSignature, true));


if (doc.FirstChild is XmlDeclaration)
{
doc.RemoveChild(doc.FirstChild);
}

// Save the signed XML document to a file specified
// using the passed string.
XmlTextWriter xmltw = new XmlTextWriter(SignedFileName, new UTF8Encoding(false));
doc.WriteTo(xmltw);
xmltw.Close();*/


}


}

celma.costa

JavaC Membro
[Avatar]

Membro desde: 29/11/2016 13:54:48
Mensagens: 9
Localização: Barueri SP
Offline

este é o xml assinado, só q com o uri em branco:


<?xml version="1.0" encoding="UTF-8"?>

-<enviNFe versao="3.10" xmlns="http://www.ahva.portalfiscal.inf.br/nfe">

<idLote>000000000000001</idLote>

<indSinc>0</indSinc>


-<NFe xmlns="http://www.portalfiscal.inf.br/nfe" xmlnssi="http://www.w3.org/2001/XMLSchema-instance">


-<infNFe versao="3.10" Id="NFe31161226242107000130550010000000181000001258">


-<ide>

<cUF>31</cUF>

<cNF>00000125</cNF>

<natOp>Venda de producao do estabelecimento</natOp>

<indPag>1</indPag>

<mod>55</mod>

<serie>1</serie>

<nNF>18</nNF>

<dhEmi>2016-12-01T12:44:05-04:00</dhEmi>

<dhSaiEnt>2016-12-01T12:44:05-04:00</dhSaiEnt>

<tpNF>1</tpNF>

<idDest>2</idDest>

<cMunFG>3106200</cMunFG>

<tpImp>1</tpImp>

<tpEmis>1</tpEmis>

<cDV>8</cDV>

<tpAmb>1</tpAmb>

<finNFe>1</finNFe>

<indFinal>0</indFinal>

<indPres>1</indPres>

<procEmi>3</procEmi>

<verProc>3.10.86</verProc>

</ide>


-<emit>

<CNPJ>26242107000130</CNPJ>

<xNome>Brazilian Support Company</xNome>


-<enderEmit>

<xLgr>Rua Nossa Senhora de Lourdes</xLgr>

<nro>111</nro>

<xBairro>Olhos D'Agua</xBairro>

<cMun>3106200</cMun>

<xMun>Belo Horizonte</xMun>

<UF>MG</UF>

<CEP>30390530</CEP>

<cPais>1058</cPais>

<xPais>BRASIL</xPais>

</enderEmit>

<IE>0626191480058</IE>

<CRT>3</CRT>

</emit>


-<dest>

<CNPJ>48707913000179</CNPJ>

<xNome>NF-E EMITIDA EM AMBIENTE DE HOMOLOGACAO - SEM VALOR FISCAL</xNome>


-<enderDest>

<xLgr>Alameda Caiapos</xLgr>

<nro>465</nro>

<xBairro>Tambore</xBairro>

<cMun>3505708</cMun>

<xMun>Barueri</xMun>

<UF>SP</UF>

<CEP>06460110</CEP>

<cPais>1058</cPais>

<xPais>BRASIL</xPais>

</enderDest>

<indIEDest>1</indIEDest>

<IE>108583488116</IE>

</dest>


-<det nItem="1">


-<prod>

<cProd>F060200</cProd>

<cEAN/>

<xProd>Guitar Gibson Les Paul Custom - Slash Signature</xProd>

<NCM>92029000</NCM>

<EXTIPI>920</EXTIPI>

<CFOP>6101</CFOP>

<uCom>pcs</uCom>

<qCom>2.0000</qCom>

<vUnCom>1399.3800</vUnCom>

<vProd>2798.76</vProd>

<cEANTrib/>

<uTrib>pcs</uTrib>

<qTrib>2.0000</qTrib>

<vUnTrib>1399.3800</vUnTrib>

<indTot>1</indTot>

<nFCI>335905D3-83B2-4DD6-9EA9-6CEF3DF894FA</nFCI>

</prod>


-<imposto>

<vTotTrib>874.59</vTotTrib>


-<ICMS>


-<ICMS00>

<orig>1</orig>

<CST>00</CST>

<modBC>3</modBC>

<vBC>2798.76</vBC>

<pICMS>12.0000</pICMS>

<vICMS>335.85</vICMS>

</ICMS00>

</ICMS>


-<IPI>

<cEnq>999</cEnq>


-<IPITrib>

<CST>50</CST>

<vBC>2798.76</vBC>

<pIPI>10.0000</pIPI>

<vIPI>279.87</vIPI>

</IPITrib>

</IPI>


-<PIS>


-<PISAliq>

<CST>01</CST>

<vBC>2798.76</vBC>

<pPIS>1.6500</pPIS>

<vPIS>46.17</vPIS>

</PISAliq>

</PIS>


-<COFINS>


-<COFINSAliq>

<CST>01</CST>

<vBC>2798.76</vBC>

<pCOFINS>7.6000</pCOFINS>

<vCOFINS>212.70</vCOFINS>

</COFINSAliq>

</COFINS>

</imposto>

<infAdProd>Resolucao do Senado Federal num 13/2012, Numero da FCI 335905D3-83B2-4DD6-9EA9-6CEF3DF894FA, CI 60%</infAdProd>

</det>


-<total>


-<ICMSTot>

<vBC>2798.76</vBC>

<vICMS>335.85</vICMS>

<vICMSDeson>0.00</vICMSDeson>

<vFCPUFDest>0.00</vFCPUFDest>

<vICMSUFDest>0.00</vICMSUFDest>

<vICMSUFRemet>0.00</vICMSUFRemet>

<vBCST>0.00</vBCST>

<vST>0.00</vST>

<vProd>2798.76</vProd>

<vFrete>0.00</vFrete>

<vSeg>0.00</vSeg>

<vDesc>0.00</vDesc>

<vII>0.00</vII>

<vIPI>279.87</vIPI>

<vPIS>46.17</vPIS>

<vCOFINS>212.70</vCOFINS>

<vOutro>0.00</vOutro>

<vNF>3078.63</vNF>

<vTotTrib>874.59</vTotTrib>

</ICMSTot>

</total>


-<transp>

<modFrete>0</modFrete>

</transp>

<infAdic/>

</infNFe>


-<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">


-<SignedInfo>

<CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>

<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>


-<Reference URI="">


-<Transforms>

<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>

<Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>

</Transforms>

<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>

<DigestValue>MFNBpkonODJaPY4L1S9kZs6AxjY=</DigestValue>

</Reference>

</SignedInfo>

<SignatureValue>cq9lPCekYm+fWbNGmENPSu2ufgjrSvLAjvt2IKcbBp1qUYVxt0vFrS04XCOCZYMMFUtGWFOSAR+H uxW67vpwmkTPai2j4BXJbvssdIYzznnMOfszDkQL2dO3Jy/yM6S5Kj+UEQEqrVeR+UrXfhd8w90S omvAGWA2RPCX62eyrAW1JJigqLV4fEvkBnJiF5FJTaaHtZ8XNx8M630QOrQENO1Ipd56oG3kiY5I XDkdKxHG4xZg/gMTfkgVcuz34rtrAi69gqA0zOQduvL66fHQqH7HJ0X6hwOYwkTT94T1MJG5s7W4 8mSs1F8kUrmJxM+t4RH2M6Oc26Per+HkHZoX4Q==</SignatureValue>


-<KeyInfo>


-<X509Data>

<X509Certificate>MIIIATCCBemgAwIBAgIQbZy7YXrEFyDCVbbcNS4pQTANBgkqhkiG9w0BAQsFADCBhjELMAkGA1UE BhMCQlIxEzARBgNVBAoTCklDUC1CcmFzaWwxSTBHBgNVBAsTQENvbXBhbmhpYSBkZSBUZWNub2xv Z2lhIGRhIEluZm9ybWFjYW8gZG8gRXN0YWRvIGRlIE1HIC0gUFJPREVNR0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SocLR6GwRrsz46ezT/qFQ1qrf9DOwZ5 EGvAEkYCK3L/lB8QfxCkdMWm2pzxzWgiOyLzA2dzKyYAuTgY51GAfym+6jnK5xUpRThTKZqbbUw4 jgk2JqD9yx/fCOFFZXKOhxeCXAg4P5WoN26dfJPaEj8g/PYtyvEmXkh69C5IOplyZKj1aN/zeY/9 Czgyw12eWzAS3TSDbUhViQ2mfITaKAX/kYzqlPU8uLrUtd+wHpmnlBt2um6WNcxf/hGrhiVqB6jQ cUvAWxZxx0WqDjuc2vXXB3RTKy2eFHBx5xROb0zPc8i3ByNK/sv5kB5c2okEi7YAWlSjyIFzYzRB /cZHHN2ZoRQnrEKFLC6Ulc4fazOT0QrrDyLRDnIL6ustWbyzf044bj6VvVxOQ0AzC3Yyhp+aG4hR sQ==</X509Certificate>

</X509Data>

</KeyInfo>

</Signature>

</NFe>

</enviNFe>
robertop

JavaC Membro

Membro desde: 10/07/2013 20:08:36
Mensagens: 163
Offline

Dei uma olhada no seu código e não consegui localizar o erro.

Vou postar o método que utilizo para assinar a nfe e verifica se você consegue utiliza-lo.

Vou dar mais uma olhada no seu código e se achar alguma coisa posto.

Sempre que você mandar algum código aqui no fórum, utilize a tag Code. Clica em Code, cola o código e clica em Code novamente para fechar.


Neste método que estou te enviando, acredito que você somente precisara mudar a forma de pagar o certificado, no meu caso eu pego no repositório do Windows.

celma.costa

JavaC Membro
[Avatar]

Membro desde: 29/11/2016 13:54:48
Mensagens: 9
Localização: Barueri SP
Offline

Robertoooo, funcionou \o/ nem acredito :-O
Q benção!
Muito obrigada, muito muito muito obrigada
robertop

JavaC Membro

Membro desde: 10/07/2013 20:08:36
Mensagens: 163
Offline

Maravilha, qualquer coisa é só postar. Abraço!
 
Índice dos Fóruns » NF-e / NFS-e / CT-e / CF-e / Certificados Digitais
Ir para:   
Powered by JForum 2.1.9 © JForum Team