9 ## first we have to determine the content
-type
13 case "PKCS8_PEM" {$content_type
= "text/plain"; $extension
= "pem"}
14 case "PKCS8_DER" {$content_type
= "application/octet-string"; $extension
= "pk8"}
15 case "OPENSSL_PRIVKEY" {$content_type
= "text/plain"; $extension
= "pem"}
16 case "PKCS12" {$content_type
= "application/octet-string"; $extension
= "p12"}
17 case "JAVA_KEYSTORE" {$content_type
= "application/octet-string"; $extension
= "jks"}
19 print
"<h1>".i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_GET_PRIVKEY_WRONG_FORMAT_TITLE')."</h1>\n";
21 print
i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_GET_PRIVKEY_WRONG_FORMAT_DESC',
22 '__FORMAT__' => $format
)."\n";
28 if (defined $password
) {
29 ## now request the key from the server
31 'IDENTIFIER' => $identifier
,
33 'PASSWORD' => $password
,
35 if (defined $csp_freeform
&& $csp_freeform ne
'') {
36 $params
->{'CSP'} = $csp_freeform
;
38 elsif (defined $csp
&& $csp ne
'') {
39 $params
->{'CSP'} = $csp
;
41 my $msg
= $context
->{client
}->send_receive_command_msg (
42 "get_private_key_for_cert",
45 my $item
= $msg
->{PARAMS
}->{PRIVATE_KEY
};
47 if (!defined $item
|| $item eq
'') {
48 print
"<h1>".i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_GET_PRIVKEY_FAILED_TITLE')."</h1>\n";
50 print
i18nGettext('I18N_OPENXPKI_CLIENT_HTML_MASON_GET_PRIVKEY_FAILED_DESC');
55 my $filename
= $m
->comp('/lib/filename_for_cert.mhtml',
56 'identifier' => $identifier
,
57 'extension' => $extension
,
61 $r
->header_out('Content-Disposition' => ("attachment; filename=$filename"));
65 $r
->headers_out
->add('Content-Disposition' => ("attachment; filename=$filename"));
67 $r
->content_type ($content_type
);