B4J Question how to sign XML documents with digital signatures

focus330

Member
Licensed User
Longtime User
Hi Enrique, hi people

It's the same problem: invoices ( xml files ) to be send to finance governance here in Italy with signature. But it must be an automatic process inside the b4j app.
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
And how is that process, broadly speaking, Enrique?
you need first to create an original chain with an xlst
B4X:
Dim ins As InputStream = File.OpenInput(File.DirApp & "\sat","cadenaoriginal_3_3.xslt")
'a lot of code here in between
Dim cadenaOriginal As String = strWriter.RunMethod("toString",Null)
after a long medling with java security features i sign it with the certificate, the key and the password
B4X:
    signer.RunMethod("update",Array(cadenaOriginal.GetBytes("UTF8")))
    
    Dim selloBytes() As Byte = signer.RunMethod("sign",Null)
    Dim sello As String = su.EncodeBase64(selloBytes)
    
    comprobante.Sello = sello

Then with that info you sign the document with the certificate, keyfile and string.

Then you have you CFDI33 xml file signed.

i guess this is the same process for any xml signing feature, but i wouldnt know.
 
Upvote 0
Top