## OpenCA - Public Web-Gateway Command
## (c) 2002-2003 by Massimiliano Pala and OpenCA Group
##
##   File Name: scepPKIOperation
##     Version: $Revision : 0.1 $
##       Brief: manage SCEP certificates/crl operations
## Description: supports handling of SCEP commands and PKI Operations
##              for enrollment.
##  Parameters: operation, message
 
sub cmdScepPKIOperation {

  my ( $operation, $message, $cert );
  my ( $h, $i, $p7_file, @certsList );

  ##// Let's get parameters
  $operation = $query->param('operation');
  $message = $query->param('message');

  $chainDir  = getRequired ( 'ChainDir' );
  $p7_file   = getRequired ( 'tempdir' ) . "/scep_pkiOp_$$.p7";

  $tools->saveFile( FILENAME=>"$p7_file", DATA=>"$message" );

  ## We have to:
  ##   1. parse the request
  ##   2. check the requirements
  ##   3. build the response
  ##   4. send back the reply

  ## Send the response to the SCEP client
  print "Content-type: x-pki-message\n\n";

  ## Now should follow the BER encoded PKI message

}
1;
