<?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="simpara">
   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>
  <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="simpara">
      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="simpara">
      Require verification of SSL certificate used.
     </p>
     <p class="simpara">
      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="simpara">
      Require verification of peer name.
     </p>
     <p class="simpara">
      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="simpara">
      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="simpara">
      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="simpara">
      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="simpara">
      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="simpara">
      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="simpara">
      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="simpara">
      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="simpara">
      Abort if the certificate chain is too deep.
     </p>
     <p class="simpara">
      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="simpara">
      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="simpara">
      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="simpara">
      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="simpara">
      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="simpara">
      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.sni-server-certs">
     <code class="parameter">SNI_server_certs</code>
     <span class="type"><a href="language.types.array.php" class="type array">array</a></span>
    </dt>
    <dd>
     <p class="simpara">
      An array of server names and their corresponding certificates to be used
      for SNI. The keys are the server names and the values are the paths to
      the certificate files on the local filesystem. The certificate files must
      be <abbr title="Privacy-Enhanced Mail">PEM</abbr> encoded and contain both the certificate and private key.
     </p>
     <p class="simpara">
      Available as of PHP 5.6.0.
     </p>
    </dd>
   
   
    <dt id="context.ssl.alpn-protocols">
     <code class="parameter">alpn_protocols</code>
     <span class="type"><a href="language.types.array.php" class="type array">array</a></span>
    </dt>
    <dd>
     <p class="simpara">
      An array of application layer protocol names to be used for ALPN (Application-Layer Protocol Negotiation).
      The values are the protocol names as strings (e.g. &quot;http/1.1&quot;, &quot;h2&quot;).
     </p>
     <p class="simpara">
      Available as of PHP 7.0.0 and OpenSSL 1.0.2.
     </p>
    </dd>
   
   
    <dt id="context.ssl.no-ticket">
     <code class="parameter">no_ticket</code>
     <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span>
    </dt>
    <dd>
     <p class="simpara">
      If set, disable TLS session tickets. This can help to enhance security by providing Perfect Forward Secrecy (PFS).
     </p>
     <p class="simpara">
      Available as of PHP 5.3.6.
     </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="simpara">
      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="simpara">
      Aborts when the remote certificate digest doesn&#039;t match the specified
      hash.
     </p>
     <p class="simpara">
      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="simpara">
      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="simpara">
      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="simpara">
      Available as of PHP 7.2.0 and OpenSSL 1.1.0.
     </p>
    </dd>
   
   
    <dt id="context.ssl.min-proto-version">
     <code class="parameter">min_proto_version</code>
     <span class="type"><a href="language.types.integer.php" class="type int">int</a></span>
    </dt>
    <dd>
     <p class="simpara">
      Sets the minimum protocol version allowed. If not specified the library default
      minimum protocol version is used. The protocol versions are described in
      <a href="https://docs.openssl.org/master/man3/SSL_CTX_set_min_proto_version/" class="link external">&raquo;&nbsp;SSL_CTX_set_min_proto_version(3)</a>.
     </p>
     <p class="simpara">
      Available as of PHP 7.3.0 and OpenSSL 1.1.0.
     </p>
    </dd>
   
   
    <dt id="context.ssl.max-proto-version">
     <code class="parameter">max_proto_version</code>
     <span class="type"><a href="language.types.integer.php" class="type int">int</a></span>
    </dt>
    <dd>
     <p class="simpara">
      Sets the maximum protocol version allowed. If not specified the library default
      maximum protocol version is used. The protocol versions are described in
      <a href="https://docs.openssl.org/master/man3/SSL_CTX_set_min_proto_version/" class="link external">&raquo;&nbsp;SSL_CTX_set_max_proto_version(3)</a>.
     </p>
     <p class="simpara">
      Available as of PHP 7.3.0 and OpenSSL 1.1.0.
     </p>
    </dd>
   
  </dl>
 </div>


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

    </thead>

    <tbody class="tbody">
     <tr>
      <td>7.3.0</td>
      <td>
       Added <code class="parameter">min_proto_version</code> and
       <code class="parameter">max_proto_version</code>. Requires OpenSSL &gt;= 1.1.0.
      </td>
     </tr>

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

     <tr>
      <td>7.0.0</td>
      <td>
       Added <code class="parameter">alpn_protocols</code>. Requires OpenSSL &gt;= 1.0.2.
      </td>
     </tr>

     <tr>
      <td>5.6.0</td>
      <td>
       Added <code class="parameter">SNI_server_certs</code>.
      </td>
     </tr>

     <tr>
      <td>5.3.6</td>
      <td>
       Added <code class="parameter">no_ticket</code>.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 notes" id="refsect1-context.ssl-notes">
  <h3 class="title">Notes</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p 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>.
   </p>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p 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.
   </p>
  </p></blockquote>
 </div>


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


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