how to sign xml with certificate

Questions, tips and tricks and techniques for scripting in Servoy

how to sign xml with certificate

Postby garroyo » Wed Feb 09, 2022 12:41 pm

Hi, I would like to know if there is a way to sign an xml with a digital certificate in Servoy
garroyo
 
Posts: 14
Joined: Mon Jan 23, 2017 2:01 pm

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

Postby garroyo » Sat Feb 12, 2022 4:49 pm

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
garroyo
 
Posts: 14
Joined: Mon Jan 23, 2017 2:01 pm

Re: how to sign xml with certificate

Postby steve1376656734 » Fri Mar 04, 2022 12:05 pm

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.
Steve
SAN Developer
There are 10 types of people in the world - those that understand binary and those that don't
steve1376656734
 
Posts: 338
Joined: Fri Aug 16, 2013 2:38 pm
Location: Ashford, UK

Re: how to sign xml with certificate

Postby garroyo » Sat Mar 05, 2022 10:42 am

OK thank you. i will try what you say
garroyo
 
Posts: 14
Joined: Mon Jan 23, 2017 2:01 pm


Return to Methods

Who is online

Users browsing this forum: No registered users and 4 guests

cron