From: Michael M Slusarz Date: Wed, 7 Oct 2009 04:17:40 +0000 (-0600) Subject: Better error handling for S/MIME certs X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=0afd4478716469eb5bd9138de6089f28ef775f63;p=horde.git Better error handling for S/MIME certs --- diff --git a/framework/Crypt/lib/Horde/Crypt/Smime.php b/framework/Crypt/lib/Horde/Crypt/Smime.php index 911351dcb..6f1097a22 100644 --- a/framework/Crypt/lib/Horde/Crypt/Smime.php +++ b/framework/Crypt/lib/Horde/Crypt/Smime.php @@ -646,20 +646,18 @@ class Horde_Crypt_Smime extends Horde_Crypt * * @param string $cert PEM format certificate * - * @return array Array containing all extractable information about - * the certificate. + * @return mixed Array containing all extractable information about + * the certificate. Returns false on error. */ public function parseCert($cert) { $cert_split = preg_split('/(-----((BEGIN)|(END)) CERTIFICATE-----)/', $cert); - if (!isset($cert_split[1])) { - $raw_cert = base64_decode($cert); - } else { - $raw_cert = base64_decode($cert_split[1]); - } + $raw_cert = base64_decode(isset($cert_split[1]) ? $cert_split[1] : $cert); $cert_data = $this->_parseASN($raw_cert); - if (!is_array($cert_data) || ($cert_data[0] == 'UNKNOWN')) { + if (!is_array($cert_data) || + ($cert_data[0] == 'UNKNOWN') || + ($cert_data[1][0] == 'UNKNOWN')) { return false; }