PHP Conference Japan 2024

MongoDB\Driver\ClientEncryption::__construct

(mongodb >=1.14.0)

MongoDB\Driver\ClientEncryption::__construct建立新的 ClientEncryption 物件

描述

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

使用指定的選項建立新的 MongoDB\Driver\ClientEncryption 物件。

參數

options

options
選項 類型 描述
keyVaultClient MongoDB\Driver\Manager 用於路由資料金鑰查詢的 Manager。此選項為必要 (與 MongoDB\Driver\Manager::createClientEncryption() 不同)。
keyVaultNamespace 字串 完整限定的命名空間 (例如 "databaseName.collectionName"),表示包含所有用於加密和解密的資料金鑰的集合。此選項為必要。
kmsProviders 陣列

一個包含一個或多個 KMS 提供者配置的文件,用於加密資料金鑰。支援的提供者包括 "aws""azure""gcp""kmip""local",且必須至少指定一個。

如果為 "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>
}

"local" 的格式如下

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

一個包含一個或多個 KMS 提供者 TLS 配置的文件。支援的提供者包括 "aws""azure""gcp""kmip"。所有提供者都支援以下選項

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

錯誤/例外

變更日誌

版本 描述
PECL mongodb 1.16.0

用於用戶端加密的 AWS KMS 提供者現在接受 "sessionToken" 選項,可用於使用臨時 AWS 憑證進行驗證。

"tlsOptions" 選項中新增了 "tlsDisableOCSPEndpointCheck"

如果為 "azure""gcp" KMS 提供者指定空文件,驅動程式將嘗試使用 » 自動憑證來設定提供者。

PECL mongodb 1.15.0

如果為 "aws" KMS 提供者指定空文件,驅動程式將嘗試使用 » 自動憑證來設定提供者。

新增註解

使用者貢獻的註解

此頁面尚無使用者貢獻的註解。
To Top