getKeyVault()현재 데이터베이스 연결에 대한
KeyVault객체를 반환합니다.KeyVault객체는 클라이언트 사이드 필드 레벨 암호화를 위한 데이터 암호화 키 관리를 지원합니다.반환합니다: 현재 데이터베이스 연결에 대한
KeyVault객체입니다.
호환성
이 명령은 다음 환경에서 호스팅되는 배포에서 사용할 수 있습니다.
- MongoDB Atlas: 클라우드에서의 MongoDB 배포를 위한 완전 관리형 서비스
MongoDB Enterprise: MongoDB의 구독 기반 자체 관리 버전
MongoDB Community: MongoDB의 소스 사용 가능 무료 자체 관리 버전
구문
getKeyVault() 의 구문은 다음과 같습니다:
keyVault = db.getMongo().getKeyVault();
KeyVault 객체를 사용하여 다음 데이터 암호화 키 관리 메서드에 액세스합니다.
행동
데이터베이스 연결 시 클라이언트 측 필드 레벨 암호화 구성 필요
다음 예에서는 클라이언트 사이드 필드 수준 암호화 구성을 위해 로컬로 managed 키 를 사용합니다.
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.
Key Vault의 고유 부분 인덱스
The getKeyVault() method automatically creates a unique index on the keyAltNames field with a partial index filter for only documents where keyAltNames exists. getKeyVault() creates this index in the key vault collection. This prevents any two data encryption keys in the same key vault from having the same key alternative name and therefore avoids ambiguity around which data encryption key is appropriate for encryption/decryption.
경고
Do not drop the unique index created by getKeyVault(). Client-Side Field Level Encryption operations depend on server-enforced uniqueness of keyAltNames. Removing the index may lead to unexpected or unpredictable behavior.
예시
다음 예에서는 클라이언트 사이드 필드 수준 암호화 구성을 위해 로컬로 managed 키 를 사용합니다.
암호화된 클라이언트 만들기
Mongo() 생성자를 클라이언트 사이드 필드 수준 암호화 옵션과 함께 사용하여 데이터베이스 연결을 생성합니다. mongodb://myMongo.example.net URI를 대상 cluster의 연결 문자열 URI 로 바꿉니다.
encryptedClient = Mongo( "mongodb://myMongo.example.net:27017/?replSetName=myMongo", autoEncryptionOpts )
Use the getKeyVault() method to retrieve the key vault object:
keyVault = encryptedClient.getKeyVault()
클라이언트 사이드 필드 레벨 암호화가 활성화된 상태에서 MongoDB 연결을 시작하는 방법에 대한 전체 설명서는 Mongo() 를 참조하세요.