PHP8 MongoDB\Driver\Manager::createClientEncryption

2024-04-08 10:15 更新

(mongoDB >=1.7.0)

MongoDB\Driver\Manager::createClientEncryption — 創(chuàng)建新的 ClientEncryption 對象

說明

final public MongoDB\Driver\Manager::createClientEncryption(array $options): MongoDB\Driver\ClientEncryption

使用指定的選項構(gòu)造新的 MongoDB\Driver\ClientEncryption 對象。

參數(shù) 

options
選項
選擇類型描述
keyVaultClientMongoDB\驅(qū)動程序\管理器用于將數(shù)據(jù)密鑰查詢路由到單獨的 MongoDB 集群的管理器。默認情況下,使用當前 Manager 和集群。
keyVaultNamespace字符串一個完全限定的命名空間(例如 ),表示包含用于加密和解密的所有數(shù)據(jù)密鑰的集合。此選項是必需的。"databaseName.collectionName"
kms提供程序數(shù)組

包含一個或多個 KMS 提供程序的配置的文檔,這些提供程序用于加密數(shù)據(jù)密鑰。支持的提供程序包括 、 、 、 和 ,并且必須至少指定一個。"aws""azure""gcp""kmip""local"

如果為 、 或 驅(qū)動程序指定了空文檔 將嘗試使用 ? 自動憑據(jù)配置提供程序。"aws""azure""gcp"

格式如下:"aws"

aws: {
    accessKeyId: <string>,
    secretAccessKey: <string>,
    sessionToken: <optional string>
}

格式如下:"azure"

azure: {
    tenantId: <string>,
    clientId: <string>,
    clientSecret: <string>,
    identityPlatformEndpoint: <optional string> // Defaults to "login.microsoftonline.com"
}

格式如下:"gcp"

gcp: {
    email: <string>,
    privateKey: <base64 string>|<MongoDB\BSON\Binary>,
    endpoint: <optional string> // Defaults to "oauth2.googleapis.com"
}

格式如下:"kmip"

kmip: {
    endpoint: <string>
}

The format for is as follows: "local"

local: {
    // 96-byte master key used to encrypt/decrypt data keys
    key: <base64 string>|<MongoDB\BSON\Binary>
}
tlsOptionsarray

A document containing the TLS configuration for one or more KMS providers. Supported providers include , , , and . All providers support the following options: "aws""azure""gcp""kmip"

<provider>: {
    tlsCaFile: <optional string>,
    tlsCertificateKeyFile: <optional string>,
    tlsCertificateKeyFilePassword: <optional string>,
    tlsDisableOCSPEndpointCheck: <optional bool>
}

返回值 

Returns a new MongoDB\Driver\ClientEncryption instance.

錯誤/異常 

  • 在參數(shù)分析錯誤時拋出 MongoDB\Driver\Exception\InvalidArgumentException。
  • 如果擴展是在沒有 libmongocrypt 支持的情況下編譯的,則拋出 MongoDB\Driver\Exception\RuntimeException

更新日志 

版本說明
PECL mongodb 1.16.0

用于客戶端加密的 AWS KMS 提供商現(xiàn)在接受一個選項,該選項可用于 使用臨時 AWS 憑證進行身份驗證。"sessionToken"

已添加到選項中。"tlsDisableOCSPEndpointCheck""tlsOptions"

如果為 或 KMS 提供程序指定了空文檔,驅(qū)動程序?qū)L試 使用 ? 自動憑據(jù)配置提供程序。"azure""gcp"

PECL mongodb 1.15.0

如果為 KMS 指定了空文檔 provider,驅(qū)動程序?qū)L試使用 ? 自動憑據(jù)配置提供程序。"aws"

PECL mongodb 1.12.0

現(xiàn)在支持將 KMIP 作為 KMS 提供商進行客戶端加密和 可以在選項中配置。"kmsProviders"

添加了選項。"tlsOptions"

PECL mongodb 1.10.0現(xiàn)在支持將 Azure 和 GCP 作為客戶端的 KMS 提供程序 加密,并且可以在選項中進行配置。Base64 編碼的字符串現(xiàn)在是 被接受為 MongoDB\BSON\Binary 的替代方法,用于 ."kmsProviders""kmsProviders"

參見 

  • MongoDB\Driver\ClientEncryption::__construct() - 創(chuàng)建新的 ClientEncryption 對象
  • MongoDB 手冊中的顯式(手動)客戶端字段級加密
以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號