public static GetSampleNFeContent ( ) : byte[] | ||
Résultat | byte[] |
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { // Get an instance of the XmlElementSignatureStarter class, responsible for receiving the signature elements and start the // signature process var signatureStarter = new XmlElementSignatureStarter(Util.GetRestPkiClient()); // Set the XML to be signed, a sample Brazilian fiscal invoice pre-generated signatureStarter.SetXml(Util.GetSampleNFeContent()); // Set the ID of the element to be signed (this ID is present in the invoice above) signatureStarter.SetToSignElementId("NFe35141214314050000662550010001084271182362300"); // Set the signature policy signatureStarter.SetSignaturePolicy(StandardXmlSignaturePolicies.PkiBrazil.NFePadraoNacional); // Optionally, set a SecurityContext to be used to determine trust in the certificate chain. Since we're using the // StandardXmlSignaturePolicies.PkiBrazil.NFePadraoNacional policy, the security context will default to PKI Brazil (ICP-Brasil) //signatureStarter.SetSecurityContext(new Guid("...")); // Note: By changing the SecurityContext above you can accept certificates from a custom security context // Call the StartWithWebPki() method, which initiates the signature. This yields the token, a 43-character // case-sensitive URL-safe string, which identifies this signature process. We'll use this value to call the // signWithRestPki() method on the Web PKI component (see javascript on the view) and also to complete the signature // on the POST action below (this should not be mistaken with the API access token). var token = signatureStarter.StartWithWebPki(); ViewState["Token"] = token; } }