I am generating an XML file with an electronic invoice (FacturaE) and the next thing I have to do is allow it to be signed with an Electronic Signature.
My problem is that I have no idea how to do it. I do not know where to start.
I have been researching this link and it seems that the fields that I have to add in the XML are these:
<ds:Signature >
<ds:SignedInfo/>
<ds:SignatureValue/>
<ds:KeyInfo>
<ds:X509Data>
<ds:X509Certificate/>
</ds:X509Data>
</ds:KeyInfo>
<ds:Object>
<xades:QualifyingProperties>
<xades:SignedProperties>
<xades:SignedSignatureProperties>
<xades:SigningTime />
<xades:SigningCertificate/>?
<xades:SignaturePolicyIdentifier/>
<xades:SignerRole/>?
</xades:SignedSignatureProperties>
</xades:SignedProperties>
<xades:UnSignedProperties/>
</xades:QualifyingProperties>
</ds:Object>
</ds:Signature>
The main problem is that I don't know where to get that information from. Will it come in a "Digital Certificate" file that I need to read? Must the user enter it by hand?
I would appreciate any ray of light on all this.
Edit to be more specific:
I am developing a Java service that generates electronic invoices in FacturaE format. As a result, the user finally downloads an invoice in XML format.
What I want to do is that the user has the possibility to digitally sign the XML file before generating it, without the need to download an unsigned XML, go to "Autosign" and sign it from there.
The signature you want to include in the XML will depend on the standard you want to use. For the example that you place it would seem to be XML-DSIG. And for that you need a library, because doing it from scratch is a lot of work. I would recommend you check out https://santuario.apache.org/