KeyVault.addKeyAlternateName()
KeyVault.addKeyAlternateName(UUID, keyAltName)
UUID
를 사용하여 데이터 암호화 키의keyAltNames
배열에keyAltName
를 추가합니다.keyAltName
must 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
클라이언트 사이드 필드 레벨 암호화 메서드를 사용하려면 클라이언트 사이드 필드 레벨 암호화를 활성화한 데이터베이스 연결이 필요합니다. 클라이언트 사이드 필드 레벨 암호화가 활성화된 상태에서 현재 데이터베이스 연결이 시작되지 않은 경우 다음 중 하나를 수행하세요.
예시
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
암호화 키 관리(Encryption Key Management).
암호화된 클라이언트 만들기
Mongo()
생성자를 클라이언트 사이드 필드 수준 암호화 옵션과 함께 사용하여 데이터베이스 연결을 생성합니다. mongodb://myMongo.example.net
URI를 대상 cluster의 연결 문자열 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 must 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
.