Bug #9426: Fix S/Mime signing
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 21 Dec 2010 21:50:50 +0000 (14:50 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 21 Dec 2010 21:51:42 +0000 (14:51 -0700)
Workaround broken openssl_pkcs7_sign() - it outputs both \r\n and \n in
the same string.

framework/Crypt/lib/Horde/Crypt/Smime.php
framework/Crypt/package.xml

index caf5acc..949975c 100644 (file)
@@ -391,7 +391,14 @@ class Horde_Crypt_Smime extends Horde_Crypt
             throw new Horde_Crypt_Exception(Horde_Crypt_Translation::t("Could not S/MIME sign message."));
         }
 
-        $data = file_get_contents($output);
+        /* Output from openssl_pkcs7_sign may contain both \n and \r\n EOLs.
+         * Canonicalize to \r\n. */
+        $fp = fopen($output, 'r');
+        stream_filter_register('horde_eol', 'Horde_Stream_Filter_Eol');
+        stream_filter_append($fp, 'horde_eol');
+        $data = stream_get_contents($fp);
+        fclose($fp);
+
         return $this->_fixContentType($data, 'signature');
     }
 
index 7956955..9956df6 100644 (file)
     <channel>pear.horde.org</channel>
    </package>
    <package>
+    <name>Stream_Filter</name>
+    <channel>pear.horde.org</channel>
+   </package>
+   <package>
     <name>Translation</name>
     <channel>pear.horde.org</channel>
    </package>