<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.mongodb-driver-manager.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'mongodb-driver-manager.createclientencryption.php',
    1 => 'MongoDB\\Driver\\Manager::createClientEncryption',
    2 => 'Create a new ClientEncryption object',
  ),
  'up' => 
  array (
    0 => 'class.mongodb-driver-manager.php',
    1 => 'MongoDB\\Driver\\Manager',
  ),
  'prev' => 
  array (
    0 => 'mongodb-driver-manager.construct.php',
    1 => 'MongoDB\\Driver\\Manager::__construct',
  ),
  'next' => 
  array (
    0 => 'mongodb-driver-manager.executebulkwrite.php',
    1 => 'MongoDB\\Driver\\Manager::executeBulkWrite',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/mongodb/mongodb/driver/manager/createclientencryption.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="mongodb-driver-manager.createclientencryption" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">MongoDB\Driver\Manager::createClientEncryption</h1>
  <p class="verinfo">(mongodb &gt;=1.7.0)</p><p class="refpurpose"><span class="refname">MongoDB\Driver\Manager::createClientEncryption</span> &mdash; <span class="dc-title">Create a new ClientEncryption object</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-mongodb-driver-manager.createclientencryption-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">final</span> <span class="modifier">public</span> <span class="methodname"><strong>MongoDB\Driver\Manager::createClientEncryption</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.array.php" class="type array">array</a></span> <code class="parameter">$options</code></span>): <span class="type"><a href="class.mongodb-driver-clientencryption.php" class="type MongoDB\Driver\ClientEncryption">MongoDB\Driver\ClientEncryption</a></span></div>

  <p class="simpara">
   Constructs a new <span class="classname"><a href="class.mongodb-driver-clientencryption.php" class="classname">MongoDB\Driver\ClientEncryption</a></span> object with the specified options.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-mongodb-driver-manager.createclientencryption-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt><code class="parameter">options</code></dt>
    <dd>
     <p class="para">
      <table class="doctable table">
       <caption><strong>options</strong></caption>
       
        <thead>
         <tr>
          <th>Option</th>
          <th>Type</th>
          <th>Description</th>
         </tr>

        </thead>

        <tbody class="tbody">
         
         <tr>
          <td>keyVaultClient</td>
          <td><span class="classname"><a href="class.mongodb-driver-manager.php" class="classname">MongoDB\Driver\Manager</a></span></td>
          <td>The Manager used to route data key queries to a separate MongoDB cluster. By default, the current Manager and cluster is used.</td>
         </tr>


         
         <tr>
          <td>keyVaultNamespace</td>
          <td><span class="type"><a href="language.types.string.php" class="type string">string</a></span></td>
          <td>A fully qualified namespace (e.g. <code class="literal">&quot;databaseName.collectionName&quot;</code>) denoting the collection that contains all data keys used for encryption and decryption. This option is required.</td>
         </tr>


         
         <tr>
          <td>kmsProviders</td>
          <td><span class="type"><a href="language.types.array.php" class="type array">array</a></span></td>
          <td>
           <p class="para">
            A document containing the configuration for one or more KMS providers, which are used to encrypt data keys. Supported providers include <code class="literal">&quot;aws&quot;</code>, <code class="literal">&quot;azure&quot;</code>, <code class="literal">&quot;gcp&quot;</code>, <code class="literal">&quot;kmip&quot;</code>, and <code class="literal">&quot;local&quot;</code> and at least one must be specified.
           </p>
           <p class="para">
            If an empty document is specified for <code class="literal">&quot;aws&quot;</code>,
            <code class="literal">&quot;azure&quot;</code>, or <code class="literal">&quot;gcp&quot;</code>, the driver
            will attempt to configure the provider using
            <a href="https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/client-side-encryption.rst#automatic-credentials" class="link external">&raquo;&nbsp;Automatic Credentials</a>.
           </p>
           <p class="para">
            The format for <code class="literal">&quot;aws&quot;</code> is as follows:
           </p>
           <div class="example-contents">
<div class="javascriptcode"><pre class="javascriptcode">aws: {
    accessKeyId: &lt;string&gt;,
    secretAccessKey: &lt;string&gt;,
    sessionToken: &lt;optional string&gt;
}</pre>
</div>
           </div>

           <p class="para">
            The format for <code class="literal">&quot;azure&quot;</code> is as follows:
           </p>
           <div class="example-contents">
<div class="javascriptcode"><pre class="javascriptcode">azure: {
    tenantId: &lt;string&gt;,
    clientId: &lt;string&gt;,
    clientSecret: &lt;string&gt;,
    identityPlatformEndpoint: &lt;optional string&gt; // Defaults to &quot;login.microsoftonline.com&quot;
}</pre>
</div>
           </div>

           <p class="para">
            The format for <code class="literal">&quot;gcp&quot;</code> is as follows:
           </p>
           <div class="example-contents">
<div class="javascriptcode"><pre class="javascriptcode">gcp: {
    email: &lt;string&gt;,
    privateKey: &lt;base64 string&gt;|&lt;MongoDB\BSON\Binary&gt;,
    endpoint: &lt;optional string&gt; // Defaults to &quot;oauth2.googleapis.com&quot;
}</pre>
</div>
           </div>

           <p class="para">
            The format for <code class="literal">&quot;kmip&quot;</code> is as follows:
           </p>
           <div class="example-contents">
<div class="javascriptcode"><pre class="javascriptcode">kmip: {
    endpoint: &lt;string&gt;
}</pre>
</div>
           </div>

           <p class="para">
            The format for <code class="literal">&quot;local&quot;</code> is as follows:
           </p>
           <div class="example-contents">
<div class="javascriptcode"><pre class="javascriptcode">local: {
    // 96-byte master key used to encrypt/decrypt data keys
    key: &lt;base64 string&gt;|&lt;MongoDB\BSON\Binary&gt;
}</pre>
</div>
           </div>

          </td>
         </tr>


         
         <tr>
          <td>tlsOptions</td>
          <td><span class="type"><a href="language.types.array.php" class="type array">array</a></span></td>
          <td>
           <p class="para">
            A document containing the TLS configuration for one or more KMS providers. Supported providers include <code class="literal">&quot;aws&quot;</code>, <code class="literal">&quot;azure&quot;</code>, <code class="literal">&quot;gcp&quot;</code>, and <code class="literal">&quot;kmip&quot;</code>. All providers support the following options:
           </p>
           <div class="example-contents">
<div class="javascriptcode"><pre class="javascriptcode">&lt;provider&gt;: {
    tlsCaFile: &lt;optional string&gt;,
    tlsCertificateKeyFile: &lt;optional string&gt;,
    tlsCertificateKeyFilePassword: &lt;optional string&gt;,
    tlsDisableOCSPEndpointCheck: &lt;optional bool&gt;
}</pre>
</div>
           </div>

          </td>
         </tr>


        </tbody>
       
      </table>

     </p>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-mongodb-driver-manager.createclientencryption-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="simpara">
   Returns a new <span class="classname"><a href="class.mongodb-driver-clientencryption.php" class="classname">MongoDB\Driver\ClientEncryption</a></span> instance.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-mongodb-driver-manager.createclientencryption-errors">
  <h3 class="title">错误／异常</h3>
  <ul class="simplelist">
   <li>Throws <span class="classname"><a href="class.mongodb-driver-exception-invalidargumentexception.php" class="classname">MongoDB\Driver\Exception\InvalidArgumentException</a></span> on argument parsing errors.</li>
   <li>Throws <span class="classname"><a href="class.mongodb-driver-exception-runtimeexception.php" class="classname">MongoDB\Driver\Exception\RuntimeException</a></span> if the extension was compiled without libmongocrypt support</li>
  </ul>
 </div>


 <div class="refsect1 changelog" id="refsect1-mongodb-driver-manager.createclientencryption-changelog">
  <h3 class="title">更新日志</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>版本</th>
      <th>说明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>PECL mongodb 1.16.0</td>
      <td>
       <span class="simpara">
        The AWS KMS provider for client-side encryption now accepts a
        <code class="literal">&quot;sessionToken&quot;</code> option, which can be used to
        authenticate with temporary AWS credentials.
       </span>
       <span class="simpara">
        Added <code class="literal">&quot;tlsDisableOCSPEndpointCheck&quot;</code> to the
        <code class="literal">&quot;tlsOptions&quot;</code> option.
       </span>
       <span class="simpara">
        If an empty document is specified for the <code class="literal">&quot;azure&quot;</code> or
        <code class="literal">&quot;gcp&quot;</code> KMS provider, the driver will attempt to
        configure the provider using
        <a href="https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/client-side-encryption.rst#automatic-credentials" class="link external">&raquo;&nbsp;Automatic Credentials</a>.
       </span>
      </td>
     </tr>

     <tr>
      <td>PECL mongodb 1.15.0</td>
      <td>
       <span class="simpara">
        If an empty document is specified for the <code class="literal">&quot;aws&quot;</code> KMS
        provider, the driver will attempt to configure the provider using
        <a href="https://github.com/mongodb/specifications/blob/master/source/client-side-encryption/client-side-encryption.rst#automatic-credentials" class="link external">&raquo;&nbsp;Automatic Credentials</a>.
       </span>
      </td>
     </tr>

     <tr>
      <td>PECL mongodb 1.12.0</td>
      <td>
       <span class="simpara">
        KMIP is now supported as a KMS provider for client-side encryption and
        may be configured in the <code class="literal">&quot;kmsProviders&quot;</code> option.
       </span>
       <span class="simpara">
        Added the <code class="literal">&quot;tlsOptions&quot;</code> option.
       </span>
      </td>
     </tr>

     <tr>
      <td>PECL mongodb 1.10.0</td>
      <td>
       Azure and GCP are now supported as KMS providers for client-side
       encryption and may be configured in the
       <code class="literal">&quot;kmsProviders&quot;</code> option. Base64-encoded strings are now
       accepted as an alternative to <span class="classname"><a href="class.mongodb-bson-binary.php" class="classname">MongoDB\BSON\Binary</a></span>
       for options within <code class="literal">&quot;kmsProviders&quot;</code>.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 seealso" id="refsect1-mongodb-driver-manager.createclientencryption-seealso">
  <h3 class="title">参见</h3>
  <ul class="simplelist">
   <li><span class="function"><a href="mongodb-driver-clientencryption.construct.php" class="function" rel="rdfs-seeAlso">MongoDB\Driver\ClientEncryption::__construct()</a> - Create a new ClientEncryption object</span></li>
   <li><a href="https://www.mongodb.com/docs/manual/core/security-explicit-client-side-encryption/" class="link external">&raquo;&nbsp;Explicit (Manual) Client-Side Field Level Encryption</a> in the MongoDB manual</li>
  </ul>
 </div>


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