<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/context.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'context.ssl.php',
    1 => 'SSL context options',
    2 => 'SSL context option listing',
  ),
  'up' => 
  array (
    0 => 'context.php',
    1 => 'Context options and parameters',
  ),
  'prev' => 
  array (
    0 => 'context.ftp.php',
    1 => 'FTP context options',
  ),
  'next' => 
  array (
    0 => 'context.phar.php',
    1 => 'Phar context options',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'language/context/ssl.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="context.ssl" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">SSL context options</h1>
  <p class="refpurpose"><span class="refname">SSL context options</span> &mdash; <span class="dc-title">SSL context option listing</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-context.ssl-description">
  <h3 class="title">Description</h3>
  <p class="para">
   Context options for <code class="literal">ssl://</code> and <code class="literal">tls://</code>
   transports.
  </p>
 </div>


 <div class="refsect1 options" id="refsect1-context.ssl-options">
  <h3 class="title">Options</h3>
  <p class="para">
   <dl>
    
     <dt id="context.ssl.peer-name">
      <code class="parameter">peer_name</code>
      <span class="type"><a href="language.types.string.php" class="type string">string</a></span>
     </dt>
     <dd>
      <p class="para">
       Peer name to be used. If this value is not set, then the name is guessed
       based on the hostname used when opening the stream.
      </p>
     </dd>
    
    
     <dt id="context.ssl.verify-peer">
      <code class="parameter">verify_peer</code>
      <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span>
     </dt>
     <dd>
      <p class="para">
       Require verification of SSL certificate used.
      </p>
      <p class="para">
       Defaults to <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>.
      </p>
     </dd>
    
    
     <dt id="context.ssl.verify-peer-name">
      <code class="parameter">verify_peer_name</code>
      <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span>
     </dt>
     <dd>
      <p class="para">
       Require verification of peer name.
      </p>
      <p class="para">
       Defaults to <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>.
      </p>
     </dd>
    
    
     <dt id="context.ssl.allow-self-signed">
      <code class="parameter">allow_self_signed</code>
      <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span>
     </dt>
     <dd>
      <p class="para">
       Allow self-signed certificates. Requires
       <a href="context.ssl.php#context.ssl.verify-peer" class="link"><code class="parameter">verify_peer</code></a>.
      </p>
      <p class="para">
       Defaults to <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>
      </p>
     </dd>
    
    
     <dt id="context.ssl.cafile">
      <code class="parameter">cafile</code>
      <span class="type"><a href="language.types.string.php" class="type string">string</a></span>
     </dt>
     <dd>
      <p class="para">
       Location of Certificate Authority file on local filesystem
       which should be used with the <code class="literal">verify_peer</code>
       context option to authenticate the identity of the remote peer.
      </p>
     </dd>
    
    
     <dt id="context.ssl.capath">
      <code class="parameter">capath</code>
      <span class="type"><a href="language.types.string.php" class="type string">string</a></span>
     </dt>
     <dd>
      <p class="para">
       If <code class="literal">cafile</code> is not specified or if the certificate
       is not found there, the directory pointed to by <code class="literal">capath</code>
       is searched for a suitable certificate.  <code class="literal">capath</code>
       must be a correctly hashed certificate directory.
      </p>
     </dd>
    
    
     <dt id="context.ssl.local-cert">
      <code class="parameter">local_cert</code>
      <span class="type"><a href="language.types.string.php" class="type string">string</a></span>
     </dt>
     <dd>
      <p class="para">
       Path to local certificate file on filesystem.  It must be a
       <abbr title="Privacy-Enhanced Mail">PEM</abbr> encoded file which contains your certificate and
       private key. It can optionally contain the certificate chain of issuers.
       The private key also may be contained in a separate file specified
       by <code class="literal">local_pk</code>.
      </p>
     </dd>
    
    
     <dt id="context.ssl.local-pk">
      <code class="parameter">local_pk</code>
      <span class="type"><a href="language.types.string.php" class="type string">string</a></span>
     </dt>
     <dd>
      <p class="para">
       Path to local private key file on filesystem in case of separate
       files for certificate (<code class="literal">local_cert</code>) and private key.
      </p>
     </dd>
    
    
     <dt id="context.ssl.passphrase">
      <code class="parameter">passphrase</code>
      <span class="type"><a href="language.types.string.php" class="type string">string</a></span>
     </dt>
     <dd>
      <p class="para">
       Passphrase with which your <code class="literal">local_cert</code> file
       was encoded.
      </p>
     </dd>
    
    
     <dt id="context.ssl.verify-depth">
      <code class="parameter">verify_depth</code>
      <span class="type"><a href="language.types.integer.php" class="type int">int</a></span>
     </dt>
     <dd>
      <p class="para">
       Abort if the certificate chain is too deep.
      </p>
      <p class="para">
       Defaults to no verification.
      </p>
     </dd>
    
    
     <dt id="context.ssl.ciphers">
      <code class="parameter">ciphers</code>
      <span class="type"><a href="language.types.string.php" class="type string">string</a></span>
     </dt>
     <dd>
      <p class="para">
       Sets the list of available ciphers. The format of the string is described
       in <a href="https://docs.openssl.org/master/man1/openssl-ciphers/" class="link external">&raquo;&nbsp;ciphers(1)</a>.
      </p>
      <p class="para">
       Defaults to <code class="literal">DEFAULT</code>.
      </p>
     </dd>
    
    
     <dt id="context.ssl.capture-peer-cert">
      <code class="parameter">capture_peer_cert</code>
      <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span>
     </dt>
     <dd>
      <p class="para">
       If set to <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> a <code class="literal">peer_certificate</code> context option
       will be created containing the peer certificate.
      </p>
     </dd>
    
    
     <dt id="context.ssl.capture-peer-cert-chain">
      <code class="parameter">capture_peer_cert_chain</code>
      <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span>
     </dt>
     <dd>
      <p class="para">
       If set to <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> a <code class="literal">peer_certificate_chain</code> context
       option will be created containing the certificate chain.
      </p>
     </dd>
    
    
     <dt id="context.ssl.sni-enabled">
      <code class="parameter">SNI_enabled</code>
      <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span>
     </dt>
     <dd>
      <p class="para">
       If set to <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> server name indication will be enabled. Enabling SNI
       allows multiple certificates on the same IP address.
      </p>
     </dd>
    
    
     <dt id="context.ssl.disable-compression">
      <code class="parameter">disable_compression</code>
      <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span>
     </dt>
     <dd>
      <p class="para">
       If set, disable TLS compression. This can help mitigate the CRIME attack
       vector.
      </p>
     </dd>
    
    
     <dt id="context.ssl.peer-fingerprint">
      <code class="parameter">peer_fingerprint</code>
      <span class="type"><a href="language.types.string.php" class="type string">string</a></span> | <span class="type"><a href="language.types.array.php" class="type array">array</a></span>
     </dt>
     <dd>
      <p class="para">
       Aborts when the remote certificate digest doesn&#039;t match the specified
       hash.
      </p>
      <p class="para">
       When a <span class="type"><a href="language.types.string.php" class="type string">string</a></span> is used, the length will determine which hashing algorithm
       is applied, either &quot;md5&quot; (32) or &quot;sha1&quot; (40).
      </p>
      <p class="para">
       When an <span class="type"><a href="language.types.array.php" class="type array">array</a></span> is used, the keys indicate the hashing algorithm name
       and each corresponding value is the expected digest.
      </p>
     </dd>
    
    
     <dt id="context.ssl.security-level">
      <code class="parameter">security_level</code>
      <span class="type"><a href="language.types.integer.php" class="type int">int</a></span>
     </dt>
     <dd>
      <p class="para">
       Sets the security level. If not specified the library default security level is used.
       The security levels are described in
       <a href="https://docs.openssl.org/master/man3/SSL_CTX_set_security_level/" class="link external">&raquo;&nbsp;SSL_CTX_get_security_level(3)</a>.
      </p>
      <p class="para">
       Available as of PHP 7.2.0 and OpenSSL 1.1.0.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-context.ssl-changelog">
  <h3 class="title">Changelog</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Version</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>7.2.0</td>
       <td>
        Added <code class="parameter">security_level</code>. Requires OpenSSL &gt;= 1.1.0.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-context.ssl-notes">
  <h3 class="title">Notes</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <span class="simpara">
    Because <code class="literal">ssl://</code> is the underlying transport for the
    <a href="wrappers.http.php" class="link"><code class="literal">https://</code></a> and
    <a href="wrappers.ftp.php" class="link"><code class="literal">ftps://</code></a> wrappers,
    any context options which apply to <code class="literal">ssl://</code> also apply to
    <code class="literal">https://</code> and <code class="literal">ftps://</code>.
   </span>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <span class="simpara">
    For SNI (Server Name Indication) to be available, then PHP must be compiled
    with OpenSSL 0.9.8j or greater. Use the
    <strong><code><a href="openssl.constsni.php#constant.openssl-tlsext-server-name">OPENSSL_TLSEXT_SERVER_NAME</a></code></strong> to determine whether SNI is
    supported.
   </span>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-context.ssl-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li><a href="context.socket.php" class="xref">Socket context options</a></li>
   </ul>
  </p>
 </div>


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