<?xml version="1.0" encoding="UTF-8"?> 
<?xml-stylesheet href="https://dev.horde.org/themes/horde//default/feed-rss.xsl" type="text/xsl"?> 
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> 
 <channel> 
  <title>smime.php extractSignedContents hangs on larger mails (openssl process never returns)</title> 
  <pubDate>Fri, 10 Apr 2026 07:03:43 +0000</pubDate> 
  <link>https://bugs.horde.org/ticket/7754</link> 
  <atom:link rel="self" type="application/rss+xml" title="smime.php extractSignedContents hangs on larger mails (openssl process never returns)" href="https://bugs.horde.org/ticket/7754/rss" /> 
  <description>smime.php extractSignedContents hangs on larger mails (openssl process never returns)</description> 
 
   
   
  <item> 
   <title>The function function extractSignedContents($data, $sslpath)</title> 
   <description>The function function extractSignedContents($data, $sslpath) in smime.php used by imp to get the mail content without signature, uses piped input for openssl communication.



This is a bad approach and not suggested by the openssl mailling list, because depending on the system it will lead to side effects. For small messages ( &lt;100kb) it will work fine, but for larger the function call never returns because a simply ps aux reveals openssl never returns.



Instead of piping the message to the openssl input, temporary file input and output should be used like all other functions already implemented in the smime.php libary.



The following corrected function will dont have any issues on any system, plus its a lot faster then piping, also the php mem size can be lower then for piping input:



/**

     * Extract the contents from signed S/MIME data.

     *

     * @param string $data     The signed S/MIME data.

     * @param string $sslpath  The path to the OpenSSL binary.

     *

     * @return string  The contents embedded in the signed data.

     *                 Returns PEAR_Error on error.

     */

    function extractSignedContents($data, $sslpath)

    {

     // dont use pipes ! openssl will hang

        /* Check for availability of OpenSSL PHP extension. */

        $openssl = $this-&gt;checkForOpenSSL();

        if (is_a($openssl, &#039;PEAR_Error&#039;)) {

            return $openssl;

        }

     

        $input = $this-&gt;_createTempFile(&#039;horde-smime&#039;);

        $output = $this-&gt;_createTempFile(&#039;horde-smime&#039;);

          

        /* Write text to file */

        $fp = fopen($input, &#039;w+&#039;);

        fwrite($fp, $data);

        fclose($fp);

        

        exec($sslpath . &#039; smime -verify -noverify -nochain -in &#039; .$input. &#039; -out &#039; .$output);        

        

        $return = file_get_contents($output);        

        return $return;

    }





This is a critical issue and should be fixed in the next release.



Thanks</description> 
   <pubDate>Fri, 05 Dec 2008 10:45:23 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/7754#t51081</link> 
  </item> 
   
  <item> 
   <title>Changes have been made in CVS for this ticket:

http://cvs.h</title> 
   <description>Changes have been made in CVS for this ticket:

http://cvs.horde.org/diff.php/framework/Crypt/Crypt/smime.php?r1=1.72&amp;r2=1.73&amp;ty=u</description> 
   <pubDate>Sun, 07 Dec 2008 19:36:04 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/7754#t51111</link> 
  </item> 
   
  <item> 
   <title>Makes sense.  Tweaked and committed to Horde 3.3.1.</title> 
   <description>Makes sense.  Tweaked and committed to Horde 3.3.1.</description> 
   <pubDate>Sun, 07 Dec 2008 19:37:37 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/7754#t51112</link> 
  </item> 
   
  <item> 
   <title>Changes have been made in Git for this ticket:

Merge fix fr</title> 
   <description>Changes have been made in Git for this ticket:

Merge fix from Ticket #7754
Use file_put_contents() when possible.

http://git.horde.org/diff.php/framework/Crypt/lib/Horde/Crypt/smime.php?rt=horde-git&amp;r1=b038b6ac295e05fb5d8e9247b52379dd17b59b40&amp;r2=bb88d985374d6daf1091ebaebf2347c5acc783ad</description> 
   <pubDate>Tue, 12 Jan 2010 23:55:27 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/7754#t57468</link> 
  </item> 
   
   
 
 </channel> 
</rss> 
