FirmaSAT Manual

Example batch file

This shows one way to make a batch file (SIGNIT.BAT) that signs a given base XML file using a hard-coded key file and certificate name. The password is correctly not hard-coded for security purposes. It can either be typed on the command line, or is prompted for.

@echo off
:: Expecting filename as first parameter...
if "%1"=="" GOTO NOFILE
SET MYFILE=%1
:: Deal with optional password and prompt if not given...
SET MYPWD=%2
if "%2"=="" set /P MYPWD=Enter password^>
:: Check if 64-bit machine and set PROGRAMFILES accordingly...
SET _pf=%PROGRAMFILES%
IF NOT "%PROGRAMFILES(X86)%"=="" SET _pf=%PROGRAMFILES(X86)%
REM ECHO %_pf%
:: Create output filename
FOR %%i IN (%MYFILE%) DO SET MYNEWFILE=%%~dpni-signed.xml
:: Do the business...
"%_pf%\FirmaSAT\FirmaSAT" SIGNXML -s @ -k emisor.key -p %MYPWD% -c emisor.cer -i %MYFILE% -o %MYNEWFILE%
SET MYPWD=
GOTO DONE
:NOFILE
echo ERROR: no filename
echo USAGE: %0 filename [password]
:DONE

This example will create a new file base-signed.xml.

SIGNIT base.xml a0123456789
[PREV: Command-line utility...]   [Contents]   [Index]   
   [NEXT: C/C++ Programming...]

Copyright © 2007-24 D.I. Management Services Pty Ltd. All rights reserved. Generated 2024-04-08T04:07:56Z.