KeyVault.removeKeyAlternateName(UUID, keyAltName)使用指定的
keyAltName从数据加密密钥中删除指定的UUID。 The data encryption key must exist in the key vault associated to the database connection.返回: 更新
keyAltName之前的数据加密密钥。如果没有数据加密密钥具有指定的 ,则返回
nullUUID()。
兼容性
此命令可用于以下环境中托管的部署:
- MongoDB Atlas:用于云中 MongoDB 部署的完全托管服务
MongoDB Enterprise:基于订阅、自我管理的 MongoDB 版本
MongoDB Community:源代码可用、免费使用且可自行管理的 MongoDB 版本
语法
removeKeyAlternateName() 通过以下语法实现:
keyVault = db.getMongo().getKeyVault() keyVault.removeKeyAlternateName( UUID("<UUID string>"), "keyAltName" )
行为
需要在数据库连接上配置客户端字段级加密
The mongosh client-side field level encryption methods require a database connection with client-side field level encryption enabled. If the current database connection was not initiated with client-side field level encryption enabled, either:
Use the
mongoshcommand line options to establish a connection with the required options. The command line options only support the Amazon Web Services KMS provider for CMK management.
例子
The following example is intended for rapid evaluation of client-side field level encryption. For specific examples of using KeyVault.removeKeyAlternateName() with each supported KMS provider, see Encryption Key Management.
Retrieve the keyVault object and use the KeyVault.removeKeyAlternateName() method to remove the specified key alternate name from the data encryption key with matching UUID:
keyVault = encryptedClient.getKeyVault() keyVault.removeKeyAlternateName(UUID("b4b41b33-5c97-412e-a02b-743498346079"),"Other-Data-Encryption-Key")
If successful, removeKeyAlternateName() returns the data encryption key prior to updating the keyAltName.
{ "_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" : Long(0), "masterKey" : { "provider" : "local" }, "keyAltNames" : [ "ssn-encryption-key" ] }