Page 1 of 1

how to sign xml with certificate

PostPosted: Wed Feb 09, 2022 12:41 pm
by garroyo
Hi, I would like to know if there is a way to sign an xml with a digital certificate in Servoy

Re: application.executeprogram. how to sign xml with certifi

PostPosted: Sat Feb 12, 2022 4:49 pm
by garroyo
I am trying to sign an .xml with digital certificate with an external program called AutoSignature, by passing parameters to it through the command line and using application.executeprogram.
I know that the parameters to pass to it so that it can be executed are correct since in cmd it is executed without problems. But when trying to run it on Servoy using application.executeprogram doesn't work.

On the command line the instruction would be:
AutoFirmaCommandLine.exe sign -certgui -i D:\\descargas\\FacturaE321.xml -o D:\\tmp\\test-firma.signed -format XadES -store windows -filter subject.contains:12710839G -xml -config xadesSignFormat ="XAdES Enveloped"

The parameters that I try to pass are correct because in cmd they work for me, but I don't know what I could be doing wrong because it doesn't execute in servoy.
If someone could tell me what I may be doing wrong I would appreciate it.

This is my code in Servoy.
//is the full path of the program to be executed.
var ruta_app = "D:\\Program Files\\AutoFirma\\AutoFirma\\AutoFirmaCommandLine.exe";

//Arguments passed to the program
var params = [" sign", " -certgui", " -i D:\\descargas\\FacturaE321.xml", " -o D:\\tmp\\test-firma.signed ", " -format XadES", " -store windows", " -filter subject.contains:12710839G", " -xml", " -config xadesSignFormat=\"XAdES Enveloped\""];

//directory from which your program start executing.
var startdirectory = "D:\\Program Files\\AutoFirma\\AutoFirma\\";

//environment variables passed to the program
var enviromentvariables = null;

var str = application.executeProgram(ruta_app, params, null, startdirectory);

This is Servoy said about the instruction of the command line
Unrecognized command: sign
...
Use "AutoSignature cmd -help" to see the syntax of the "cmd" command

Re: how to sign xml with certificate

PostPosted: Fri Mar 04, 2022 12:05 pm
by steve1376656734
You could try removing the space character in " sign" as this is being passed as part of the parameter. You should do this for all the parameters.

Re: how to sign xml with certificate

PostPosted: Sat Mar 05, 2022 10:42 am
by garroyo
OK thank you. i will try what you say