From 2d06be19a609b70731e38d08e2cb4a3d71223d3b Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 18 Jan 2011 01:25:05 -0700 Subject: [PATCH] Bug #9514: Fix importing S/MIME key --- imp/lib/Mime/Viewer/Smime.php | 2 +- imp/smime.php | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/imp/lib/Mime/Viewer/Smime.php b/imp/lib/Mime/Viewer/Smime.php index cc45347b5..7169ff9ca 100644 --- a/imp/lib/Mime/Viewer/Smime.php +++ b/imp/lib/Mime/Viewer/Smime.php @@ -295,7 +295,7 @@ class IMP_Mime_Viewer_Smime extends Horde_Mime_Viewer_Base isset($sig_result->email) && $GLOBALS['registry']->hasMethod('contacts/addField') && $GLOBALS['prefs']->getValue('add_source')) { - $status[] = '[' . $this->getConfigParam('imp_contents')->linkViewJS($this->_mimepart, 'view_attach', _("View Certificate"), array('params' => array('mode' => IMP_Contents::RENDER_INLINE, 'view_smime_key' => 1))) . '] [' . Horde::link('#', '', null, null, $this->_impsmime->savePublicKeyURL($this->getConfigParam('imp_contents')->getMailbox(), $this->getConfigParam('imp_contents')->getUid(), $sig_id) . ' return false;') . _("Save Certificate in your Address Book") . ']'; + $status[] = '[' . $this->getConfigParam('imp_contents')->linkViewJS($this->_mimepart, 'view_attach', _("View Certificate"), array('params' => array('mode' => IMP_Contents::RENDER_INLINE, 'view_smime_key' => 1))) . '] [' . Horde::link('#', '', null, null, $this->_impsmime->savePublicKeyURL($this->getConfigParam('imp_contents')->getMailbox(), $this->getConfigParam('imp_contents')->getUid(), $base_id) . ' return false;') . _("Save Certificate in your Address Book") . ']'; } } catch (Horde_Exception $e) { self::$_cache[$base_id]['status'][0]['icon'] = Horde::img('alerts/error.png', _("Error")); diff --git a/imp/smime.php b/imp/smime.php index 838b786bc..5ad54a1c4 100644 --- a/imp/smime.php +++ b/imp/smime.php @@ -105,15 +105,21 @@ case 'save_attachment_public_key': $contents = $injector->getInstance('IMP_Injector_Factory_Contents')->create(new IMP_Indices($vars->mailbox, $vars->uid)); $mime_part = $contents->getMIMEPart($vars->mime_id); if (empty($mime_part)) { - throw new IMP_Exception('Cannot retrieve public key from message.'); + throw new IMP_Exception(_("Cannot retrieve public key from message.")); } /* Add the public key to the storage system. */ try { - $imp_smime->addPublicKey($mime_part); + $stream = $vars->mime_id + ? $contents->getBodyPart($vars->mime_id, array('mimeheaders' => true, 'stream' => true)) + : $contents->fullMessageText(); + $raw_text = $mime_part->replaceEOL($stream, Horde_Mime_Part::RFC_EOL); + + $sig_result = $imp_smime->verifySignature($raw_text); + $imp_smime->addPublicKey($sig_result->cert); echo Horde::wrapInlineScript(array('window.close();')); } catch (Horde_Exception $e) { - $notification->push(_("No Certificate found"), 'horde.error'); + throw new IMP_Exception(_("No certificate found.")); } break; } -- 2.11.0