## OpenCA - CA Command
## (c) 1998-2001 by Massimiliano Pala and OpenCA Group
##
##   File Name: exportCAReq
##     Version: $Revision: 1.5 $
##//       Brief: Exports CA's Request
##// Description: Exports CA's Certificate Request

require "$common_libs/export-import.lib";

sub cmdExportCAReq {

    ## To export the CA request and CA certificate we use
    ## the same export device as the one used for the certificates
    ## (is there any reason for not doing so ?)
    ## Get required parameters from the configuration file
    my $reqDir 	= getRequired( 'ReqDir' );

    ## Other reserved variables
    my ( $dir, $file );

    ## If we want to export the cacert.pem the $dir must be
    ## set to the main OpenCA directory. If we want to export
    ## the request for the CA, just set the $dir to the
    ## $pendingreqs set in the config file.
    $dir = "$reqDir";
    $file = "careq.pem";
    configError (i18nGettext ("Cannot find file __FILE__!", "__FILE__", "$dir/$file"))
        if (not -e "$dir/$file" );

    print startLogPage (gettext ("Export CA Certificate Signing Request"));

    eximIOExport (DIR => $reqDir);

    closePage();

}

1;

