AI 에이전트의 경우: 문서 인덱스는 https://www.mongodb.com/ko-kr/docs/llms.txt에서 사용할 수 있으며, 모든 페이지의 마크다운 버전은 어떤 URL 경로에 .md를 추가하여 사용할 수 있습니다.
Docs Menu

getKeyVault() (mongosh 메서드)

getKeyVault()

현재 데이터베이스 연결에 대한 KeyVault 객체를 반환합니다. KeyVault 객체는 클라이언트 사이드 필드 레벨 암호화를 위한 데이터 암호화 키 관리를 지원합니다.

반환합니다:

현재 데이터베이스 연결에 대한 KeyVault 객체입니다.

이 명령은 다음 환경에서 호스팅되는 배포에서 사용할 수 있습니다.

  • MongoDB Atlas: 클라우드에서의 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:

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 키 를 사용합니다.

1

mongosh 클라이언트를 시작합니다.

mongosh --nodb
2

로컬로 managed 키에 대한 클라이언트 사이드 필드 수준 암호화를 구성하려면 줄바꿈 없이 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를 대상 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() 를 참조하세요.

이 페이지 평가하기

이 페이지의 내용