KeyVault.addKeyAlternateName()
KeyVault.addKeyAlternateName(UUID, keyAltName)
UUID
を使用してデータ暗号化キーのkeyAltNames
配列にkeyAltName
を追加します。keyAltName
する必要がある be unique among all keys in the key vault. ThegetKeyVault()
method automatically creates a 一意なインデックス on thekeyAltNames
field with a partial index filter for only documents wherekeyAltNames
exists.次の値を返します。 Returns the previous version of the data encryption key document. 戻り値
null
if no data encryption key has the specifiedUUID()
.
互換性
このコマンドは、次の環境でホストされている配置で使用できます。
MongoDB Atlas はクラウドでの MongoDB 配置のためのフルマネージド サービスです
MongoDB Enterprise: サブスクリプションベースの自己管理型 MongoDB バージョン
MongoDB Community: ソースが利用可能で、無料で使用できる自己管理型の MongoDB のバージョン
構文
addKeyAlternateName()
の構文は次のとおりです。
keyVault = db.getMongo().getKeyVault() keyVault.addKeyAlternateName( UUID("<UUID string>"), "keyAlternateName" )
動作
データベース接続にクライアント側のフィールドレベル暗号化を構成する必要があります
mongosh
クライアント側のフィールド レベル暗号化メソッドでは、クライアント側のフィールド レベル暗号化が有効になっているデータベース接続が必要です。現在のデータベース接続がクライアント側のフィールド レベル暗号化を有効にして開始されなかった場合、次のいずれかが発生します。
Mongo()
必要なクライアント側のフィールドレベル暗号化オプションとの接続を確立するには、mongosh
から コンストラクターを使用します。Mongo()
メソッドは、CMK(Customer Master Key)管理のために次のKMS ( KMS )プロバイダーをサポートしています。or
必要なオプションとの接続を確立するには、
mongosh
コマンドライン オプションを使用します。 コマンドライン オプションは、CMK 管理用のAmazon Web Services KMSプロバイダーのみをサポートしています。
例
The following example is intended for rapid evaluation of
client-side field level encryption. For specific examples of using
KeyVault.addKeyAlternateName()
with each supported
KMS provider, see
暗号化キー管理.
暗号化されたクライアントの作成
データベース接続を作成するには、クライアント側のフィールドレベル暗号化オプションが構成されたMongo()
コンストラクターを使用します。 mongodb://myMongo.example.net
URI を、ターゲットクラスターの接続string URIに置き換えます。
encryptedClient = Mongo( "mongodb://myMongo.example.net:27017/?replSetName=myMongo", autoEncryptionOpts )
Retrieve the KeyVault
object and use the
KeyVault.addKeyAlternateName()
method to add a new key
alternate name to the data encryption key with matching UUID
. The
specified key alternate name する必要がある be unique:
keyVault = encryptedClient.getKeyVault() keyVault.addKeyAlternateName(UUID("b4b41b33-5c97-412e-a02b-743498346079"),"Other-Data-Encryption-Key")
If successful, addKeyAlternateName()
returns the
previous version of data encryption key document:
{ "_id" : UUID("b4b41b33-5c97-412e-a02b-743498346079"), "keyMaterial" : BinData(0,"PXRsLOAYxhzTS/mFQAI8486da7BwZgqA91UI7NKz/T/AjB0uJZxTvhvmQQsKbCJYsWVS/cp5Rqy/FUX2zZwxJOJmI3rosPhzV0OI5y1cuXhAlLWlj03CnTcOSRzE/YIrsCjMB0/NyiZ7MRWUYzLAEQnE30d947XCiiHIb8a0kt2SD0so8vZvSuP2n0Vtz4NYqnzF0CkhZSWFa2e2yA=="), "creationDate" : ISODate("2019-08-12T21:21:30.569Z"), "updateDate" : ISODate("2019-08-12T21:21:30.569Z"), "status" : 0, "version" : NumberLong(0), "masterKey" : { "provider" : "local" }, "keyAltNames" : [ ] }
To view the current version of the data encryption key document, use
KeyVault.getKey()
specifying the _id
of the returned
document or KeyVault.getKeyByAltName()
specifying one of the
keyAltNames
.