Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages


home | help
OpenXPKI::Crypto::CLI(User Contributed Perl DocumentatOpenXPKI::Crypto::CLI(3)


       This module is an ABSTRACT superclass that implements basic handling of
       calling command line binarys. Note that it can not be instantiated.

       The new function	creates	a new instance of this class. There are	the
       following parameters:

       o   SHELL (the location of the binary to	use)

       o   ENGINE (a reference to an Engine object)

       o   TMP (the temporary directory)

       This prepares a command array to	be executed. The only parameter	is
       COMMAND which must either contain a string or an	array reference.  The
       parameter is appended to	the shell command.

       performs	the commands. It throws	an exception on	error. The behaviour
       of this function	is a little bit	difficult. The simplest	way is that
       you use the function without any	arguments. This	means that you have
       passed all parameters via the command line parameters and you get the
       the result via the function get_result or you used an explicit output

       Example:	$cli->execute();

       The function supports another way too. Sometimes	it is necessary	to
       pass input directly or to read the output directly beause it is
       critical	data which should never	be stored on a disk. You can use the
       parameter PARAMS	in this	case. You have to specify for each command
       which you specified via prepare a type and if necessary the data.

       Example:	$cli->prepare ({COMMAND	=> ["command1 -params ...",
					    "command2 -params ...",
					    "command3 -params ...",
					    "command4 -params ..."]});
		my $params = [
			      {TYPE => "STDIN",	DATA =>	"the input data"},
			      {TYPE => "STDOUT"},
			      {TYPE => "NOTHING"},
			      {TYPE => "STDOUT"},
		my $result = $cli->execute ({PARAMS => $params});

       The first command is an example for using STDIN.	The specified data
       will be passed via STDIN	to the command.	The second command passes the
       result via STDOUT directly into the code. This means that $result
       contains	the result from	the queries two	and four. If you need the
       results seperately the please look into $params->[1]->{STDOUT} and
       $params->[3]->{STDOUT}. The third query simply enforces normal
       behaviour via files.

       returns the result of the commands which	were executed with run_cmd.
       If there	was no output then 1 will be returned.

       This function is	to be implemented by children classes. It is executed
       right before the	command	is executed, so	shell environment variables
       that are	relevant for the command can be	set here (e.g. OPENSSL_CONF in
       the OpenSSL case).

       This function is	to be implemented by the children classes. It gets the
       STDERR output as	a string, which	it can parse for errors. Depending on
       whether there are errors	or not,	it has to return true or false.

       my $cli = OpenXPKI::Crypto::Backend::OpenSSL::CLI->new
		     TMP    => "/tmp",
		     SHELL  => "/usr/local/ssl/bin/openssl",
		     ENGINE => $engine
		 }); $cli->prepare ({COMMAND =>	['x509 -in cert.pem -outform
       DER -out	cert.der']}); $cli->execute ();	## senseless here because the
       result is in cert.der ##	$cli->get_result(); undef $cli;	## now do
       something with cert.der

See also
       OpenXPKI::Crypto::Backend::OpenSSL::CLI - The CLI class for OpenSSL
       OpenXPKI::Crypto::Tool::SCEP::CLI       - The CLI class for openca-scep

perl v5.32.0			  2020-08-29	      OpenXPKI::Crypto::CLI(3)

Name | Desription | Functions | Example | See also

Want to link to this manual page? Use this URL:

home | help