|
| 1 | +.. _qe-fundamentals-manual-encryption: |
| 2 | + |
| 3 | +================= |
| 4 | +{+manual-enc-title+} |
| 5 | +================= |
| 6 | + |
| 7 | +.. default-domain:: mongodb |
| 8 | + |
| 9 | +.. contents:: On this page |
| 10 | + :local: |
| 11 | + :backlinks: none |
| 12 | + :depth: 2 |
| 13 | + :class: singlecol |
| 14 | + |
| 15 | +Overview |
| 16 | +-------- |
| 17 | + |
| 18 | +Learn how to use the **{+manual-enc+}** mechanism of {+qe+}. |
| 19 | + |
| 20 | +.. include:: /includes/fact-manual-enc-definition.rst |
| 21 | + |
| 22 | +{+manual-enc-first+} is available in the following MongoDB products |
| 23 | +using version 6.0 or later: |
| 24 | + |
| 25 | +- MongoDB Community Server |
| 26 | +- MongoDB Enterprise Advanced |
| 27 | +- MongoDB Atlas |
| 28 | + |
| 29 | +Use {+manual-enc-title+} |
| 30 | +--------------------- |
| 31 | + |
| 32 | +To use {+manual-enc+} you must perform the following actions in your |
| 33 | +{+qe+}-enabled application: |
| 34 | + |
| 35 | +- :ref:`qe-fundamentals-manual-encryption-client-enc` |
| 36 | +- :ref:`qe-fundamentals-manual-encryption-update-operations` |
| 37 | +- :ref:`qe-fundamentals-manual-encryption-automatic-decryption` |
| 38 | + |
| 39 | +.. _qe-fundamentals-manual-encryption-client-enc: |
| 40 | + |
| 41 | +Create a ``ClientEncryption`` Instance |
| 42 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 43 | + |
| 44 | +``ClientEncryption`` is an abstraction used across drivers and |
| 45 | +:binary:`~bin.mongosh` that encapsulates the {+key-vault-long+} |
| 46 | +and {+kms-abbr+} operations involved in {+manual-enc+}. |
| 47 | + |
| 48 | +To create a ``ClientEncryption`` instance, specify: |
| 49 | + |
| 50 | +- A ``kmsProviders`` object configured with access to the |
| 51 | + {+kms-abbr+} hosting your {+cmk-long+} |
| 52 | +- The namespace of your {+key-vault-long+} |
| 53 | +- If you use MongoDB Community Server, set the ``bypassQueryAnalysis`` |
| 54 | + option to ``True`` |
| 55 | +- A ``MongoClient`` instance with access to your {+key-vault-long+} |
| 56 | + |
| 57 | +For more ``ClientEncryption`` options, see :ref:`qe-reference-mongo-client`. |
| 58 | + |
| 59 | +.. note:: |
| 60 | + |
| 61 | + Code examples are not currently available but are coming soon. |
| 62 | + |
| 63 | +.. _qe-fundamentals-manual-encryption-update-operations: |
| 64 | + |
| 65 | +Encrypt Fields in Read and Write Operations |
| 66 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 67 | + |
| 68 | +You must update read and write operations throughout your application |
| 69 | +such that your application encrypts fields before performing |
| 70 | +read and write operations. |
| 71 | + |
| 72 | +To encrypt fields, use the ``encrypt`` method of your ``ClientEncryption`` |
| 73 | +instance. Specify the following: |
| 74 | + |
| 75 | +- The value to be encrypted |
| 76 | +- The algorithm used, either ``"Indexed"`` or ``"Unindexed"`` |
| 77 | +- The ID of the {+dek-long+} |
| 78 | +- The contention factor (if you are using the ``INDEXED`` algorithm) |
| 79 | +- The query type defined for your field (if you are using the ``INDEXED`` algorithm) |
| 80 | + |
| 81 | +.. note:: Query Types |
| 82 | + |
| 83 | + The query type only applies when the algorithm is set to ``INDEXED``. |
| 84 | + |
| 85 | + To learn more about query types, see :ref:`qe-query-types`. |
| 86 | + |
| 87 | +.. TODO: Need tech review on this section to ensure correctness and potentially add details |
| 88 | + |
| 89 | +Algorithm Choice |
| 90 | +```````````````` |
| 91 | + |
| 92 | +If you specify a ``queryType`` on a field, use the ``Indexed`` algorithm to encrypt and decrypt that field. |
| 93 | + |
| 94 | +.. _qe-fundamentals-manual-encryption-automatic-decryption: |
| 95 | + |
| 96 | +Automatic Decryption |
| 97 | +~~~~~~~~~~~~~~~~~~~~ |
| 98 | + |
| 99 | +To decrypt your fields automatically, you must configure your |
| 100 | +``MongoClient`` instance as follows: |
| 101 | + |
| 102 | +- Specify a ``kmsProviders`` object |
| 103 | +- Specify your {+key-vault-long+} |
| 104 | +- If you use MongoDB Community Server, set the ``bypassQueryAnalysis`` |
| 105 | + option to ``True`` |
| 106 | + |
| 107 | +.. note:: Automatic Decryption is Available in MongoDB Community Server |
| 108 | + |
| 109 | + Although automatic encryption requires MongoDB Enterprise or MongoDB |
| 110 | + Atlas, automatic decryption is available in the following MongoDB |
| 111 | + products using version 6.0 or later: |
| 112 | + |
| 113 | + - MongoDB Community Server |
| 114 | + - MongoDB Enterprise Advanced |
| 115 | + - MongoDB Atlas |
| 116 | + |
| 117 | +.. _qe-fundamentals-manual-encryption-server-side-schema: |
| 118 | + |
| 119 | +Server-Side Field Level Encryption Enforcement |
| 120 | +---------------------------------------------- |
| 121 | + |
| 122 | +You can also :ref:`qe-specify-fields-for-encryption` to enforce |
| 123 | +encryption of specific fields in a collection. |
| 124 | + |
| 125 | +A client performing {+qe+} with the {+manual-enc+} |
| 126 | +mechanism on a MongoDB instance configured to enforce encryption |
| 127 | +of certain fields must encrypt those fields as specified on |
| 128 | +the MongoDB instance. |
| 129 | + |
| 130 | +To learn how to set up server-side {+qe+} |
| 131 | +enforcement, see :ref:`qe-fundamentals-encrypt-query`. |
| 132 | + |
| 133 | +Learn More |
| 134 | +---------- |
| 135 | + |
| 136 | +To learn more about {+key-vault-long+}s, {+dek-long+}s, and {+cmk-long+}s, |
| 137 | +see :ref:`csfle-reference-keys-key-vaults`. |
| 138 | + |
| 139 | +To learn more about {+kms-abbr+} providers and ``kmsProviders`` objects, |
| 140 | +see :ref:`csfle-reference-kms-providers`. |
0 commit comments