对于 AI 代理:可在 https://www.mongodb.com/zh-cn/docs/llms.txt 获取文档索引—通过在任何 URL 路径后添加 .md 可获取所有页面的 Markdown 版本。
Docs 菜单

KeyVault.removeKeyAlternateName()(mongosh方法)

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 部署的完全托管服务

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:

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.

1

启动mongosh客户端。

mongosh --nodb
2

要为本地托管的密钥配置客户端字段级加密,请生成一个不带换行符的 base64 编码的 96 字节字符串。

const TEST_LOCAL_KEY = require("crypto").randomBytes(96).toString("base64")
3

使用生成的本地密钥字符串创建客户端字段级加密选项:

let autoEncryptionOpts = {
"keyVaultNamespace" : "encryption.__dataKeys",
"kmsProviders" : {
"local" : {
"key" : BinData(0, TEST_LOCAL_KEY)
}
}
}
4

使用配置了客户端字段级加密选项的Mongo()构造函数来创建数据库连接。 将mongodb://myMongo.example.net URI 替换为目标集群的连接字符串 URI

encryptedClient = Mongo(
"mongodb://myMongo.example.net:27017/?replSetName=myMongo",
autoEncryptionOpts
)

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"
]
}
给本页内容打分