KeyVault.createKey(keyManagementService, customerMasterKey, ["keyAltName"])데이터베이스 연결과 연결된 주요 키 모음에 데이터 암호화 키를 추가합니다. 클라이언트 측 필드 레벨 암호화 는 데이터 암호화 키를 사용하여 필드 값의 암호화 및 암호 해독을 지원합니다.
반환합니다: 생성된 데이터 암호화 키의
UUID고유 식별자입니다.
호환성
이 명령은 다음 환경에서 호스팅되는 배포에서 사용할 수 있습니다.
- MongoDB Atlas: 클라우드에서의 MongoDB 배포를 위한 완전 관리형 서비스
MongoDB Enterprise: MongoDB의 구독 기반 자체 관리 버전
MongoDB Community: MongoDB의 소스 사용 가능 무료 자체 관리 버전
구문
createKey() 의 구문은 다음과 같습니다:
keyVault = db.getMongo().getKeyVault() keyVault.createKey( keyManagementService, customerMasterKey, [ "keyAltName" ] )
Parameter | 유형 | 설명 |
|---|---|---|
| 문자열 | 필수 사항 고객 마스터 키(CMK)를 검색하는 데 사용할 키 관리 서비스(KMS) 입니다. 다음 매개변수를 허용합니다:
지정된 KMS로 |
| 문자열 또는 문서 | 데이터 암호화 키를 암호화하는 데 사용할 고객 마스터 키(CMK)입니다. KMS 제공자에 따라 다음과 같이 고객 마스터 키를 제공합니다.
이 매개변수는 |
| 문자열 배열 | 옵션 데이터 암호화 키의 대체 이름입니다. 메서드는 가 존재하는 문서에 대해서만 부분 인덱스 필터를 사용하여 필드에 고유 |
| 문서 | 옵션 새 키에 대한 옵션을 지정하는 문서입니다.
|
행동
데이터베이스 연결 시 클라이언트 측 필드 레벨 암호화 구성 필요
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.createKey() with each supported KMS provider, see Create a Data Key.
암호화된 클라이언트 만들기
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.createKey() method to create a new data encryption key using the locally managed key:
keyVault = encryptedClient.getKeyVault() keyVault.createKey("local", ["data-encryption-key"])
If successful, createKey() returns the UUID of the new data encryption key. To retrieve the new data encryption key document from the key vault, either:
getKey()을(를) 사용하여UUID에서 생성한 키를 조회합니다.-또는-
대체 이름으로 키를 조회하려면
getKeyByAltName()를 사용합니다.