<%args> $identifier => undef $format => "PKCS8_PEM" $password => undef $csp => undef $csp_freeform => undef <%init> ## first we have to determine the content-type my $content_type; my $extension; switch ($format) { case "PKCS8_PEM" {$content_type = "text/plain"; $extension = "pem"} case "PKCS8_DER" {$content_type = "application/octet-string"; $extension = "pk8"} case "OPENSSL_PRIVKEY" {$content_type = "text/plain"; $extension = "pem"} case "PKCS12" {$content_type = "application/octet-string"; $extension = "p12"} case "JAVA_KEYSTORE" {$content_type = "application/octet-string"; $extension = "jks"} else { print "

".i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_GET_PRIVKEY_WRONG_FORMAT_TITLE')."

\n"; print "

\n"; print i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_GET_PRIVKEY_WRONG_FORMAT_DESC', '__FORMAT__' => $format)."\n"; print "

\n"; return 1; } } if (defined $password) { ## now request the key from the server my $params = { 'IDENTIFIER' => $identifier, 'FORMAT' => $format, 'PASSWORD' => $password, }; if (defined $csp_freeform && $csp_freeform ne '') { $params->{'CSP'} = $csp_freeform; } elsif (defined $csp && $csp ne '') { $params->{'CSP'} = $csp; } my $msg = $context->{client}->send_receive_command_msg ( "get_private_key_for_cert", $params, ); my $item = $msg->{PARAMS}->{PRIVATE_KEY}; if (!defined $item || $item eq '') { print "

".i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_GET_PRIVKEY_FAILED_TITLE')."

\n"; print "

\n"; print i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_GET_PRIVKEY_FAILED_DESC'); print "

\n"; return 1; } ## now send the stuff my $filename = $m->comp('/lib/filename_for_cert.mhtml', 'identifier' => $identifier, 'extension' => $extension, ); eval { $r->header_out('Content-Disposition' => ("attachment; filename=$filename")); }; if ($EVAL_ERROR) { # mod_perl 2 $r->headers_out->add('Content-Disposition' => ("attachment; filename=$filename")); } $r->content_type ($content_type); print $item; return 1; } <%once> use Switch; use English;