<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.openssl.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'it',
  ),
  'this' => 
  array (
    0 => 'function.openssl-pkcs7-decrypt.php',
    1 => 'openssl_pkcs7_decrypt',
    2 => 'Decrypts an S/MIME encrypted message',
  ),
  'up' => 
  array (
    0 => 'ref.openssl.php',
    1 => 'OpenSSL Funzioni',
  ),
  'prev' => 
  array (
    0 => 'function.openssl-pkcs12-read.php',
    1 => 'openssl_pkcs12_read',
  ),
  'next' => 
  array (
    0 => 'function.openssl-pkcs7-encrypt.php',
    1 => 'openssl_pkcs7_encrypt',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/openssl/functions/openssl-pkcs7-decrypt.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.openssl-pkcs7-decrypt" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">openssl_pkcs7_decrypt</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.6, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">openssl_pkcs7_decrypt</span> &mdash; <span class="dc-title">Decrypts an S/MIME encrypted message</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.openssl-pkcs7-decrypt-description">
  <h3 class="title">Descrizione</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>openssl_pkcs7_decrypt</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$input_filename</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$output_filename</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="attribute"><a href="class.sensitiveparameter.php">#[\SensitiveParameter]</a> </span><span class="type"><span class="type"><a href="class.opensslcertificate.php" class="type OpenSSLCertificate">OpenSSLCertificate</a></span>|<span class="type"><a href="language.types.string.php" class="type string">string</a></span></span> <code class="parameter">$certificate</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="attribute"><a href="class.sensitiveparameter.php">#[\SensitiveParameter]</a> </span><span class="type"><span class="type"><a href="class.opensslasymmetrickey.php" class="type OpenSSLAsymmetricKey">OpenSSLAsymmetricKey</a></span>|<span class="type"><a href="class.opensslcertificate.php" class="type OpenSSLCertificate">OpenSSLCertificate</a></span>|<span class="type"><a href="language.types.array.php" class="type array">array</a></span>|<span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.null.php" class="type null">null</a></span></span> <code class="parameter">$private_key</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span><br>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="para rdfs-comment">
   Decrypts the S/MIME encrypted message contained in the file specified by
   <code class="parameter">input_filename</code> using the certificate and its
   associated private key specified by <code class="parameter">certificate</code> and
   <code class="parameter">private_key</code>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.openssl-pkcs7-decrypt-parameters">
  <h3 class="title">Elenco dei parametri</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">input_filename</code></dt>
     <dd>
      <p class="para">
      </p>
     </dd>
    
    
     <dt><code class="parameter">output_filename</code></dt>
     <dd>
      <p class="para">
       The decrypted message is written to the file specified by
       <code class="parameter">output_filename</code>.
      </p>
     </dd>
    
    
     <dt><code class="parameter">certificate</code></dt>
     <dd>
      <p class="para">
      </p>
     </dd>
    
    
     <dt><code class="parameter">private_key</code></dt>
     <dd>
      <p class="para">
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.openssl-pkcs7-decrypt-returnvalues">
  <h3 class="title">Valori restituiti</h3>
  <p class="para">
   Restituisce <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> in caso di successo, <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> in caso di fallimento.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.openssl-pkcs7-decrypt-changelog">
  <h3 class="title">Log delle modifiche</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Versione</th>
      <th>Descrizione</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       <code class="parameter">private_key</code> accepts an <span class="classname"><a href="class.opensslasymmetrickey.php" class="classname">OpenSSLAsymmetricKey</a></span>
       or <span class="classname"><a href="class.opensslcertificate.php" class="classname">OpenSSLCertificate</a></span> instance now;
       previously, a <a href="language.types.resource.php" class="link">resource</a> of type <code class="literal">OpenSSL key</code> or <code class="literal">OpenSSL X.509 CSR</code>
       was accepted.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.openssl-pkcs7-decrypt-examples">
  <h3 class="title">Esempi</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Example #1 <span class="function"><strong>openssl_pkcs7_decrypt()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">// $cert and $key are assumed to contain your personal certificate and private<br />// key pair, and that you are the recipient of an S/MIME message<br /></span><span style="color: #0000BB">$infilename </span><span style="color: #007700">= </span><span style="color: #DD0000">"encrypted.msg"</span><span style="color: #007700">;  </span><span style="color: #FF8000">// this file holds your encrypted message<br /></span><span style="color: #0000BB">$outfilename </span><span style="color: #007700">= </span><span style="color: #DD0000">"decrypted.msg"</span><span style="color: #007700">; </span><span style="color: #FF8000">// make sure you can write to this file<br /><br /></span><span style="color: #007700">if (</span><span style="color: #0000BB">openssl_pkcs7_decrypt</span><span style="color: #007700">(</span><span style="color: #0000BB">$infilename</span><span style="color: #007700">, </span><span style="color: #0000BB">$outfilename</span><span style="color: #007700">, </span><span style="color: #0000BB">$cert</span><span style="color: #007700">, </span><span style="color: #0000BB">$key</span><span style="color: #007700">)) {<br />    echo </span><span style="color: #DD0000">"decrypted!"</span><span style="color: #007700">;<br />} else {<br />    echo </span><span style="color: #DD0000">"failed to decrypt!"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
 </div>


</div><?php manual_footer($setup); ?>