From dc4a825c54629fbb8d043b8e0f8167405394f88b Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Thu, 26 Jan 2017 17:44:30 +0100 Subject: [PATCH] WIP of SMIME support: Import certificate key into pkey in addressbook --- admin/inc/class.admin_mail.inc.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/admin/inc/class.admin_mail.inc.php b/admin/inc/class.admin_mail.inc.php index 292d85195a..bacb2e68eb 100644 --- a/admin/inc/class.admin_mail.inc.php +++ b/admin/inc/class.admin_mail.inc.php @@ -959,7 +959,21 @@ class admin_mail { case 'application/x-pkcs12': $cert_info = $smime->extractCertPKCS12($pkcs12, $content['smime_pkcs12_password']); - $content['acc_smime_password'] = $cert_info['pkey']; + if (is_array($cert_info)) + { + $content['acc_smime_password'] = $cert_info['pkey']; + if ($cert_info['cert']) + { + $AB_bo = new addressbook_bo(); + $AB_bo->set_smime_keys(array( + $content['ident_email'] => $cert_info['cert'] + )); + } + } + else + { + $tpl->set_validation_error('smimeKeyUpload', lang('Could not extract private key from given p12 file. Either the p12 file is broken or password is wrong!')); + } break; case 'application/x-iwork-keynote-sffkey': $content['acc_smime_password'] = $pkcs12;