PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
The following functions are used to handle the Windows certificates:
CertificateCheckDuplicateChecks the signature of a duplicate.
CertificateCheckFileSignatureBufferChecks the correspondence between a signature and a file. The signature was stored as a Buffer variable.
CertificateCheckFileSignatureFileChecks the correspondence between a signature and a file. The signature was kept as an external file.
CertificateCheckStringChecks the correspondence between a signature and a string.
CertificateExtractExtracts a certificate from a signature buffer or from a print duplicate.
CertificateListReturns the list of certificates available on the computer.
CertificateLoadLoads a certificate from a file or a buffer.
CertificateOpenPropertiesOpens the Windows window used to find out the properties of a certificate.
CertificateSelectOpens a window for selecting the certificates. The listed certificates are the certificates installed in the personal store.
CertificateSignExecutableSigns an executable file with a certificate.
CertificateSignFileCreates the signature of a file. This signature can be stored in a Buffer variable or in a text file.
CertificateSignStringCreates the signature of a character string.
Versions 24 and later
TrustedCertificateAdd
New in version 24
TrustedCertificateAdd
TrustedCertificateAdd
Adds a certificate to the list of trusted root authorities used to validate certification strings.
Versions 24 and later
TrustedCertificateReset
New in version 24
TrustedCertificateReset
TrustedCertificateReset
Removes all the certificates added by TrustedCertificateAdd.
Minimum required version
  • Version 16
This page is also available for…
Comments
Assinatura Digital nfe - Parte 3/... - Assinar Documento
Nessa aula vou Mostrar como Assinar um Documento Xml
This lesson will show how Subscribe to a XML Document
Cette leçon montrera comment Abonnez-vous à un document XML
//--
//Buscar arquivo xml a assinar // search xml file to sign // rechercher ujn fichier xml pourr signer
_xml_assinar is string=fLoadText("D:\arquivo_xml\43160603850874000126550010000035551000142204-nfe.xml",foUnicode)
EDT_xml=_xml_assinar
sRefuri is string="infNFe"
chavenfe is string="NFe43160603850874000126550010000035551000142204"
s_retorno is string=assinar_nfe(_xml_assinar,sRefuri,chavenfe)
IF s_retorno=-1 THEN
EDT_xml_assinado="Erro assinar"
ELSE
EDT_xml_assinado=s_retorno
END
//--
PROCEDURE assinar_nfe(_recebe_xml,_refUri,_ChNfe)

//_refUri= (sRefUri IS STRING = "infNFe")
clX509certi is X509Certificate2("D:\certificado_2016\certificado.pfx","senha")
clDoc is System.Xml.XmlDocument;
clDoc.LoadXml(_recebe_xml) // Ler um arquivo Xml // read an xml file // lire un fichir xml //
//certificado com endereco e senha //certificate with address and password //le certificat avec adresse et mot de pass
//ver se Refuri existe //Refers to see there //fait référence à y voir
qtderefuri is int= clDoc.GetElementsByTagName(_refUri).Count
IF (qtderefuri) =0 THEN
//nao existe // does not exists // ne pas exister
ELSE
//cria um objeto assinado // creat a signed object // créer un objet signé
VrSignedXml is SignedXml(clDoc)
// adiciona a chave do certificado // add the key certificate // ajouter le certificat de clé
VrSignedXml.SigningKey = clX509certi.PrivateKey
// Cria a referencia para assinatura // creates a reference to signature // crée une référence à la signature
Reference is Reference //= new Reference();
Reference.Uri = "#" + _ChNfe
// adiciona um XmlDsigEnvelopedSignatureTransform para a assinatura // add a XmlDsigEnvelopedSignatureTransform for signature
// ajouter un XmlDsigEnvelopedSignatureTransform à la signature
Env is XmlDsigEnvelopedSignatureTransform
Reference.AddTransform(Env)
c14 is XmlDsigC14NTransform
Reference.AddTransform(c14)
// adiciona a referencia no xml assinado // add the reference in xlm signed // ajouter la référence en xml singé
VrSignedXml.AddReference(Reference)
// Cria a chave // creates the key // crée la clé
VrkeyInfo is KeyInfo
// carrega o certificado em um keyinfox509 e adiciona ao keyinfo // load the certificate in a keyinfo x509 and add to keyinfo
// chager le certificat dans un x509 keyinfo et ajouter à kyinfo
VrkeyInfo.AddClause(new KeyInfoX509Data(clX509certi))
// adiciona o keyinfo ao xml assinado // add keyinfo the xml signed // ajouter keyinfo le xml signé
VrSignedXml.KeyInfo = VrkeyInfo
VrSignedXml.ComputeSignature()
// busca a representacao XML da assinatura e salva no XML // search the xml representantion of the signature and saved in xml
// rechercher la représentation xml de la signature et enregistré en xml
xmlDigitalSignature is System.Xml.XmlElement dynamic = VrSignedXml.GetXml()
// adiciona a assinatura no documento // add the signature in the document // ajouter la signature dans le document
clDoc.DocumentElement.AppendChild(clDoc.ImportNode(xmlDigitalSignature, True))
//salva o documento assinado // save the signed document // enregistrer le document signé
RESULT clDoc.get_InnerXml()

END
RESULT -1
//--

//Blog com Video e Exemplo
http://windevdesenvolvimento.blogspot.com.br/2016/06/curso-windev-certificado-007-assinatura.html
https://www.youtube.com/watch?v=uVLpstx5cRk

De matos AMARILDO
Jun. 27 2016