From eaf23c171704362fdf3d7e27200ffdf540642c20 Mon Sep 17 00:00:00 2001 From: jim-p Date: Tue, 14 Feb 2012 13:52:34 -0500 Subject: Add button to download a .p12 of a cert+key. Implements #2147 --- usr/local/www/system_certmanager.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'usr/local') diff --git a/usr/local/www/system_certmanager.php b/usr/local/www/system_certmanager.php index 5820dd1..753d713 100644 --- a/usr/local/www/system_certmanager.php +++ b/usr/local/www/system_certmanager.php @@ -144,6 +144,28 @@ if ($act == "key") { exit; } +if ($act == "p12") { + if (!$a_cert[$id]) { + pfSenseHeader("system_certmanager.php"); + exit; + } + + $exp_name = urlencode("{$a_cert[$id]['descr']}.p12"); + + $res_crt = openssl_x509_read(base64_decode($a_cert[$id]['crt'])); + $res_key = openssl_pkey_get_private(array(0 => base64_decode($a_cert[$id]['prv']) , 1 => "")); + + $exp_data = ""; + openssl_pkcs12_export($res_crt, $exp_data, $res_key, null); + $exp_size = strlen($exp_data); + + header("Content-Type: application/octet-stream"); + header("Content-Disposition: attachment; filename={$exp_name}"); + header("Content-Length: $exp_size"); + echo $exp_data; + exit; +} + if ($act == "csr") { if (!$a_cert[$id]) { @@ -961,6 +983,9 @@ function internalca_change() { " alt="" width="17" height="17" border="0" /> + + " alt="" width="17" height="17" border="0" /> + ')"> " alt="" width="17" height="17" border="0" /> -- cgit v1.1