KeyVault.addKeyAlternateName(UUID, keyAltName)UUID를 사용하여 데이터 암호화 키의keyAltNames배열에keyAltName를 추가합니다.keyAltNameKey Vault의 모든 키 중에서 고유 해야 합니다 . 메서드는 가 존재하는 문서에 대해서만 부분 인덱스 필터를 사용하여 필드에 고유getKeyVault()인덱스 를 자동으로 생성합니다.keyAltNameskeyAltNames반환합니다: 데이터 암호화 키 문서의 이전 버전을 반환합니다.
지정된
UUID()이 있는 데이터 암호화 키가 없는 경우null을 반환합니다.
호환성
이 명령은 다음 환경에서 호스팅되는 배포에서 사용할 수 있습니다.
- MongoDB Atlas: 클라우드에서의 MongoDB 배포를 위한 완전 관리형 서비스
MongoDB Enterprise: MongoDB의 구독 기반 자체 관리 버전
MongoDB Community: MongoDB의 소스 사용 가능 무료 자체 관리 버전
구문
addKeyAlternateName() 의 구문은 다음과 같습니다:
keyVault = db.getMongo().getKeyVault() keyVault.addKeyAlternateName( UUID("<UUID string>"), "keyAlternateName" )
행동
데이터베이스 연결 시 클라이언트 측 필드 레벨 암호화 구성 필요
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.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" : Long(0), "masterKey" : { "provider" : "local" }, "keyAltNames" : [ ] }
데이터 암호화 키 문서의 현재 버전을 보려면 반환된 KeyVault.getKey() _id 문서의 을 지정하는 을 사용 하거나 중 KeyVault.getKeyByAltName() 하나를 지정하는 를 keyAltNames 사용합니다.