## OpenCA - RA Server Command
## (c) 1998-2001 by Massimiliano Pala and OpenCA Group
##
##   File Name: send_cert_key
##       Brief: send cert and keypair
##     Version: $Revision: 1.3 $
##// Description: this RA-script is used to give the user it's private key and cert
##  Parameters: key, dataType, format, passwd

sub cmdSend_cert_key {

	my $tempDir = getRequired ('TempDir');

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

	my $outform  = $format;
	$outform  =~ s/^.*_//;
	my $standard = $format;
	$standard =~ s/_.*$//;

	if ($standard =~ /pkcs12/) {
		## pkcs 12
		libDoCommand ("send_cert_key_pkcs12");
	} elsif ($standard =~ /pkcs8/) {
		## pkcs 8
		$query->param (-name => 'encoding', -value => $outform);
		libDoCommand ("send_cert_key_pkcs8");
	} elsif ($standard =~ /openssl/i) {
		## old openssl rsa
		$query->param (-name => 'encoding', -value => $outform);
		libDoCommand ("send_cert_key_openssl");
	} else {
		configError (i18nGettext ("Unknown standard __STANDARD__.", "__STANDARD__", uc($standard)));
	}
}

1;
