platform-encryption-configure
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseConfigure Platform Encryption
配置Platform Encryption
Configures Salesforce Shield Platform Encryption by generating the metadata that turns it on and choosing the right settings: which encryption scheme a field should use, which key-management model fits a requirement, and how the tenant-secret lifecycle works. This is a hybrid skill — it emits deployable / where Platform Encryption exposes a real Metadata API surface, and returns grounded guidance where the operation is UI/REST-only.
*.settings-meta.xml*.field-meta.xml通过生成启用它的元数据并选择合适的设置来配置Salesforce Shield Platform Encryption:包括字段应使用的加密方案、符合需求的密钥管理模型,以及租户密钥生命周期的运作方式。这是一个混合技能——当Platform Encryption提供真实Metadata API接口时,它会生成可部署的 / 文件;当操作仅支持UI/REST时,它会返回基于实际情况的指导。
*.settings-meta.xml*.field-meta.xmlScope
适用范围
- In scope: choosing and applying on a field; enabling deterministic encryption, Cache-Only Keys, External Key Management, and replay detection via
encryptionScheme/PlatformEncryptionSettings; explaining BYOK / BYOKMS / EKM / Cache-Only key models; tenant-secret rotation and destruction semantics; the query behavior of encrypted fields.EncryptionKeySettings - Out of scope: a plain custom field with no encryption (use ); the raw Metadata API field reference (use
platform-custom-field-generate); Classic Encryption (platform-metadata-api-context-getfields) — that is a separate, legacy feature; deploying/pushing metadata to an org (that belongs to a deploy lifecycle skill).EncryptedText
- 包含范围:为字段选择并应用;通过
encryptionScheme/PlatformEncryptionSettings启用确定性加密、仅缓存密钥、外部密钥管理和重放检测;解释BYOK/BYOKMS/EKM/仅缓存密钥模型;租户密钥轮换和销毁的语义;加密字段的查询行为。EncryptionKeySettings - 排除范围:无加密的普通自定义字段(请使用);原始Metadata API字段参考(请使用
platform-custom-field-generate);Classic Encryption(platform-metadata-api-context-get字段)——这是一个独立的旧版功能;将元数据部署/推送到组织(属于部署生命周期技能的范畴)。EncryptedText
Required Inputs
必要输入
Gather or infer before proceeding:
- Question type: is the user asking for a deployable artifact (a settings file, an encrypted field) or guidance (which model, what happens when I rotate a key)? Deployable → generate XML from . Guidance → answer from
assets/. A question is guidance whenever the ask is to explain, confirm, or compare — "is that right?", "what's the relationship?", "can we…?", "is there an ordering requirement?", "explain the difference between X and Y", "which key model should we use?" — even if the user also says they are about to write, deploy, or author settings themselves. The user writing settings is their action; it does not make the skill's deliverable a file. Only an explicit "generate / create / give me the file / here is my field, encrypt it" is an artifact request.references/ - Key-model choice questions are guidance, not deployable metadata. "Explain BYOK vs external key management / BYOKMS / EKM / Cache-Only", "which one keeps key material out of Salesforce?", "should we use BYOK or EKM?" → answer them in a single markdown answer file (the guidance write-up), not a deployable . Naming the enabling setting in that answer (e.g.
*.settings-meta.xml,canExternalKeyManagement) does NOT turn it into a settings artifact — cite the field name inline in the answer file; do not emit anenableCacheOnlyKeysunless the user explicitly says "generate/create the settings file."EncryptionKey.settings-meta.xml - Field encryption target (for field work): the object and field API name, and whether the user needs to filter, sort, or group on the field (drives deterministic vs probabilistic).
- Key model (for key work): whether keys are Salesforce-derived (default), customer-supplied (BYOK), stored in an external KMS (BYOKMS/EKM), or fetched on demand (Cache-Only).
If the request is clear, generate or answer immediately — do not interrogate the user.
在执行前需收集或推断:
- 问题类型:用户是请求可部署工件(设置文件、加密字段)还是指导建议(选择哪种模型、密钥轮换会发生什么)?如果是可部署工件→从生成XML;如果是指导建议→从
assets/获取答案。只要用户的问题是解释、确认或比较类的,即为指导建议——比如“这样对吗?”、“两者关系是什么?”、“我们能否……?”、“有没有顺序要求?”、“解释X和Y的区别”、“我们应该使用哪种密钥模型?”——即使用户同时提到他们即将编写、部署或创建设置文件。用户编写设置是他们的操作,并不意味着技能的交付物是文件。只有明确要求“生成/创建/给我文件/这是我的字段,请加密它”时,才属于工件请求。references/ - 密钥模型选择类问题属于指导建议,而非可部署元数据。“解释BYOK与外部密钥管理/BYOKMS/EKM/仅缓存密钥的区别”、“哪种模型能让密钥材料不存储在Salesforce中?”、“我们应该使用BYOK还是EKM?”→用单个Markdown答案文件(指导文档)回答,而非可部署的文件。在答案中提及启用设置(如
*.settings-meta.xml、canExternalKeyManagement)并不等同于生成设置工件——在答案文件中内联引用字段名称即可;除非用户明确要求“生成/创建设置文件”,否则不要生成enableCacheOnlyKeys。EncryptionKey.settings-meta.xml - 字段加密目标(针对字段操作):对象和字段API名称,以及用户是否需要对该字段进行筛选、排序或分组(这会决定使用确定性还是概率性加密)。
- 密钥模型(针对密钥操作):密钥是Salesforce派生(默认)、客户提供(BYOK)、存储在外部KMS(BYOKMS/EKM)还是按需获取(仅缓存)。
如果请求明确,立即生成或回答——无需询问用户。
Workflow
工作流程
-
Classify the request — deployable artifact vs guidance, using the Required Inputs above. Then scope the output to exactly what was asked:
- A guidance question produces exactly one markdown answer file — a single file (e.g. ) containing the full written diagnosis/explanation — and nothing else. Do not also emit a
answer.md, a*.settings-meta.xml, or a second helper doc. This covers every "what happens when…?", "how do I…?", "which model…?", "is X right…?", "can we…?", "what's the relationship / ordering…?" question, including query-behavior and Cache-Only/replay questions. A clause like "before I write our settings" or "before I author the file" describes the user's next step and does NOT turn the question into a deployable-metadata request — write the answer file, not a settings file.*.field-meta.xml - Naming a metadata change in a guidance answer does NOT mean emitting the deployable file for it. A remediation or diagnosis question — "how do I make the field queryable?", "why did my query fail and how do I fix it?", "which key model keeps material out of Salesforce?" — is answered inside the one markdown answer file, naming the relevant element/scheme inline (e.g. "switch to a scheme and enable
Deterministic*", or "use External Key Management —enableDeterministicEncryption"). Do not additionally materialize acanExternalKeyManagementor*.field-meta.xmlto demonstrate that change — mentioning the element in the answer is the complete deliverable. Produce a deployable metadata file only when the user explicitly says generate/create/give me the field or settings file.*.settings-meta.xml - An artifact request gets only the specific metadata file(s) named — do not add a ,
DEPLOYMENT_GUIDE.md, anREADME.md, an org-EXPLANATION.mdfile, or any companion artifact the user did not ask for.settings - If a deploy step or org setting is a prerequisite, state it inside the one answer file (for guidance) or in a code comment inside the one artifact (for an artifact request) — never as an extra file.
- A guidance question produces exactly one markdown answer file — a single file (e.g.
-
For field encryption — readto choose the scheme, then load
references/encryption-schemes.mdas the starting template. Setassets/encrypted-field.field-meta.xmlto exactly one of the four valid enum values (see the reference). OnlyencryptionSchemeschemes are filterable.Deterministic*Write the field file at the SFDX source path, not the root. Amust live at*.field-meta.xml(e.g.objects/<ObjectApiName>/fields/<FieldApiName>__c.field-meta.xml) — the object folder uses the object's API name (objects/Patient__c/fields/Diagnosis_Notes__c.field-meta.xmlfor a custom object,Patient__cfor a standard one) and the file is named after the field API name. Emitting the file at the repo root, in a flat directory, or under any other folder is a structural miss even when the XML itself is correct.Contact -
For org-level encryption settings — load(deterministic encryption, field-history encryption, MEK permission) or
assets/PlatformEncryption.settings-meta.xml(Cache-Only, EKM, Data 360, transactional DB, replay detection). Readassets/EncryptionKey.settings-meta.xmlbefore setting any key-model field.references/key-models.mdName the output file after the Settings member, not the root element, and write it under. Asettings/file must beSettings, wheresettings/<member>.settings-meta.xmlis the org's metadata member name —<member>(rootEncryptionKey) and<EncryptionKeySettings>(rootPlatformEncryption). Put it in the<PlatformEncryptionSettings>source folder (e.g.settings/), not the repo root. Naming the key-settings filesettings/EncryptionKey.settings-meta.xmlorEncryption.settings-meta.xmlfails deployment with "The object '…' of type Settings metadata does not exist."EncryptionKeySettings.settings-meta.xmlCache-Only Keys and replay detection are a one-way dependency, not an auto-enable. You may setonly afterenableReplayDetectionisenableCacheOnlyKeys; enabling Cache-Only does not turn replay detection on by itself. An org can validly run Cache-Only with replay detection off.true -
For tenant-secret operations (rotate, destroy, BYOK upload, Cache-Only callout setup) — read. These are UI/REST-only; capture the guidance in the single markdown answer file, not a deployable metadata file.
references/tenant-secret-lifecycle.md -
Validate any generated settings XML — runwith the file path as its argument, and fix anything it reports. It checks the replay-detection dependency and the
scripts/validate-encryption-metadata.shenum deterministically.encryptionScheme -
Compare against the worked example — verify a generatedfile against
EncryptionKeySettings.examples/cache-only-keys.settings-meta.xml
-
分类请求——根据上述必要输入,判断是可部署工件还是指导建议。然后严格按照请求内容生成输出:
- 指导建议类问题仅生成一个Markdown答案文件——单个文件(如)包含完整的诊断/解释内容——无其他内容。不要同时生成
answer.md、*.settings-meta.xml或辅助文档。这涵盖所有“当……时会发生什么?”、“我该如何……?”、“哪种模型……?”、“X是否正确……?”、“我们能否……?”、“关系/顺序是什么……?”问题,包括查询行为和仅缓存密钥/重放检测相关问题。诸如“在我编写设置之前”或“在我创建文件之前”的表述描述的是用户的下一步操作,并不将问题转化为可部署元数据请求——应编写答案文件,而非设置文件。*.field-meta.xml - 在指导建议答案中提及元数据变更并不意味着要生成对应的可部署文件。修复或诊断类问题——“我该如何让字段可查询?”、“我的查询为什么失败,该如何修复?”、“哪种密钥模型能让材料不存储在Salesforce中?”——都应在单个Markdown答案文件中回答,内联提及相关元素/方案(如“切换到方案并启用
Deterministic*”,或“使用外部密钥管理——enableDeterministicEncryption”)。不要额外生成canExternalKeyManagement或*.field-meta.xml来演示该变更——在答案中提及元素即为完整交付物。仅当用户明确要求生成/创建/提供字段或设置文件时,才生成可部署元数据文件。*.settings-meta.xml - 工件请求仅生成用户指定的特定元数据文件——不要添加、
DEPLOYMENT_GUIDE.md、README.md、组织设置文件或任何用户未请求的辅助工件。EXPLANATION.md - 如果部署步骤或组织设置是前提条件,应在指导建议的单个答案文件中说明,或在工件请求的单个工件的代码注释中说明——绝不作为额外文件提供。
- 指导建议类问题仅生成一个Markdown答案文件——单个文件(如
-
字段加密操作——阅读选择方案,然后加载
references/encryption-schemes.md作为起始模板。将assets/encrypted-field.field-meta.xml设置为四个有效枚举值之一(请参考文档)。只有encryptionScheme方案支持筛选。Deterministic*将字段文件写入SFDX源路径,而非根目录。文件必须存放在*.field-meta.xml路径下(例如objects/<ObjectApiName>/fields/<FieldApiName>__c.field-meta.xml)——对象文件夹使用对象的API名称(自定义对象为objects/Patient__c/fields/Diagnosis_Notes__c.field-meta.xml,标准对象为Patient__c),文件名称与字段API名称一致。即使XML内容正确,将文件放在仓库根目录、扁平目录或其他文件夹下也属于结构错误。Contact -
组织级加密设置操作——加载(确定性加密、字段历史加密、MEK权限)或
assets/PlatformEncryption.settings-meta.xml(仅缓存密钥、EKM、Data 360、事务型数据库、重放检测)。在设置任何密钥模型字段之前,阅读assets/EncryptionKey.settings-meta.xml。references/key-models.md输出文件以Settings成员命名,而非根元素,并写入目录。Settings文件必须命名为settings/,其中settings/<member>.settings-meta.xml是组织的元数据成员名称——<member>(根元素EncryptionKey)和**<EncryptionKeySettings>**(根元素PlatformEncryption)。将文件放在<PlatformEncryptionSettings>源文件夹下(例如settings/),而非仓库根目录。将密钥设置文件命名为settings/EncryptionKey.settings-meta.xml或Encryption.settings-meta.xml会导致部署失败,错误信息为*“类型为Settings的对象'…'不存在。”*EncryptionKeySettings.settings-meta.xml仅缓存密钥和重放检测是单向依赖关系,而非自动启用。只有当设为enableCacheOnlyKeys后,才能设置true;启用仅缓存密钥并不会自动开启重放检测。组织可以在仅缓存密钥启用的情况下关闭重放检测,这是有效的配置。enableReplayDetection -
租户密钥操作(轮换、销毁、BYOK上传、仅缓存密钥调用设置)——阅读。这些操作仅支持UI/REST;将指导内容写入单个Markdown答案文件,而非可部署元数据文件。
references/tenant-secret-lifecycle.md -
验证生成的设置XML——运行并传入文件路径,修复所有检测到的问题。该脚本会检查重放检测依赖关系和
scripts/validate-encryption-metadata.sh枚举的确定性。encryptionScheme -
与示例对比——将生成的文件与
EncryptionKeySettings进行验证。examples/cache-only-keys.settings-meta.xml
Rules / Constraints
规则/约束
| Constraint | Rationale |
|---|---|
| These are the only values the Metadata API accepts ( |
Set | The contract is "Requires enableCacheOnlyKeys=true before setting enableReplayDetection to true" — a one-way dependency. |
| Use deterministic schemes only when the field must be filtered, sorted, or grouped | Probabilistic is stronger but non-filterable; deterministic trades some cryptographic strength for queryability. |
| Never claim a filter/sort/group on a probabilistically-encrypted field silently returns zero rows | The platform rejects the query with |
Do not emit | The WSDL element is |
| Transactional-DB, EKM, and Data 360 key fields require API 63.0+ | |
A guidance question produces exactly one markdown answer file — never a deployable | The answer file is the user's reference document — it persists in the workspace and can be shared or revised. Emitting a deployable metadata file for a guidance question is unsolicited configuration that could be accidentally applied; emitting no file leaves the user without a tangible deliverable. |
| An artifact request emits only the metadata file(s) asked for — no companion files | Adding a |
| 约束 | 理由 |
|---|---|
| 这些是Metadata API( |
仅当 | 契约规定*“在将enableReplayDetection设为true之前,必须将enableCacheOnlyKeys设为true”*——这是单向依赖关系。 |
| 仅当字段需要筛选、排序或分组时,才使用确定性方案 | 概率性加密安全性更高但不支持筛选;确定性加密以部分加密强度为代价换取可查询性。 |
| 绝不要声称对概率性加密字段进行筛选/排序/分组会静默返回零行 | 平台会以 |
不要使用 | WSDL元素是 |
| 事务型数据库、EKM和Data 360密钥字段需要API 63.0+ | |
指导建议类问题仅生成一个Markdown答案文件——绝不生成可部署的 | 答案文件是用户的参考文档——会保存在工作区中,可共享或修订。为指导建议类问题生成可部署元数据文件属于未经请求的配置,可能会被意外应用;不生成文件则会让用户没有有形的交付物。 |
| 工件请求仅生成用户请求的元数据文件——无辅助文件 | 添加用户未请求的 |
Gotchas
注意事项
| Issue | Resolution |
|---|---|
| Filtering/sorting/grouping on a probabilistically-encrypted field | The query is rejected with |
| Assuming Cache-Only Keys auto-enables replay detection | It does not. Set |
| Case sensitivity in deterministic matching | |
| Confusing BYOK with BYOKMS/EKM | BYOK = you upload key material Salesforce stores; BYOKMS/EKM = key material stays in your external KMS. See |
Using | Wrong element. The field is |
| Classic Encryption vs Shield | |
| 问题 | 解决方案 |
|---|---|
| 对概率性加密字段进行筛选/排序/分组 | 查询会被拒绝并返回 |
| 假设仅缓存密钥会自动启用重放检测 | 事实并非如此。需显式设置 |
| 确定性匹配中的大小写敏感性 | |
| 将BYOK与BYOKMS/EKM混淆 | BYOK = 用户上传密钥材料,由Salesforce存储;BYOKMS/EKM = 密钥材料保留在用户的外部KMS中。请参见 |
使用 | 元素名称错误。正确字段为 |
| Classic Encryption与Shield混淆 | |
Output Expectations
输出预期
Deliverables depend on the request — produce exactly these and nothing more:
- Guidance questions produce exactly ONE markdown answer file. Any "what happens when…", "how do I…", "which model…", "is X right…" question — including encrypted-field query behavior, Cache-Only/replay-detection relationships, tenant-secret / BYOK / Cache-Only lifecycle, and key-model choices — is answered by writing a single markdown file (e.g. ) that fully captures the diagnosis/explanation. Do not additionally emit a deployable
answer.md/*.settings-meta.xmlor a second doc, and do not answer with no file at all — the answer file is the user's persistent reference document.*.field-meta.xml - Field encryption artifact: only the with
*.field-meta.xmlset, written atencryptionScheme. Not a settings file, not a deploy guide. Pickobjects/<ObjectApiName>/fields/<FieldApiName>__c.field-meta.xmlto match the request:<type>for a string field up to 255 chars;Textonly when the field must exceed 255 chars (256+). "Long text … up to 255 characters" is aLongTextAreafield, notText. Strip the template's instructional comment block from the delivered file — ship clean metadata. Keep the accompanying chat prose tight — one or two sentences naming the scheme chosen and why (e.g. "ProbabilisticEncryption — strongest at-rest protection; the field can't be filtered/sorted/grouped, which matches your no-query requirement"). Do not restate the whole prompt, enumerate every scheme, or add setup/deployment walkthroughs; the deliverable is the file, not an essay.LongTextArea - Org settings artifact: only the settings file the request needs, at named after its Metadata API member —
settings/<member>.settings-meta.xml(rootsettings/PlatformEncryption.settings-meta.xml) and/or<PlatformEncryptionSettings>(rootsettings/EncryptionKey.settings-meta.xml). Do not name the file after the root element, and do not drop it at the repo root.<EncryptionKeySettings>
Do not add companion files (, , an extra org-settings file) that the user did not ask for — state prerequisites in a code comment inside the artifact, or inside the single answer file for guidance. File structure follows the templates in .
DEPLOYMENT_GUIDE.mdREADME.mdassets/交付物取决于请求——严格生成以下内容,无额外内容:
- 指导建议类问题仅生成一个Markdown答案文件。任何“当……时会发生什么”、“我该如何……”、“哪种模型……”、“X是否正确……”的问题——包括加密字段查询行为、仅缓存密钥/重放检测关系、租户密钥/BYOK/仅缓存密钥生命周期、密钥模型选择——都通过编写单个Markdown文件(如)来回答,文件需完整包含诊断/解释内容。不要额外生成可部署的
answer.md/*.settings-meta.xml或第二个文档,也不要仅口头回答而不生成文件——答案文件是用户的持久参考文档。*.field-meta.xml - 字段加密工件:仅包含设置了的
encryptionScheme文件,路径为*.field-meta.xml。不要生成设置文件或部署指南。根据请求选择objects/<ObjectApiName>/fields/<FieldApiName>__c.field-meta.xml:**<type>用于长度不超过255字符的字符串字段;Text**仅用于长度超过255字符的字段(256+)。“最长255字符的长文本”属于LongTextArea字段,而非Text。移除交付文件中的模板注释块——提供干净的元数据。配套的聊天内容要简洁——用一到两句话说明选择的方案及原因(例如“ProbabilisticEncryption——最强的静态数据保护;该字段无需筛选/排序/分组,符合您的需求”)。不要重述整个请求、枚举所有方案或添加设置/部署步骤;交付物是文件,而非文章。LongTextArea - 组织设置工件:仅生成请求所需的设置文件,路径为,以Metadata API成员命名——
settings/<member>.settings-meta.xml(根元素settings/PlatformEncryption.settings-meta.xml)和/或<PlatformEncryptionSettings>(根元素settings/EncryptionKey.settings-meta.xml)。不要以根元素命名文件,也不要将文件放在仓库根目录。<EncryptionKeySettings>
不要添加用户未请求的辅助文件(、、额外组织设置文件)——前提条件应放在工件的代码注释中,或指导建议的单个答案文件中。文件结构遵循中的模板。
DEPLOYMENT_GUIDE.mdREADME.mdassets/Cross-Skill Integration
跨技能集成
| Need | Delegate to |
|---|---|
| A custom field with no encryption | |
| The raw Metadata API type/field reference | |
| 需求 | 委托给 |
|---|---|
| 无加密的自定义字段 | |
| 原始Metadata API类型/字段参考 | |
Reference File Index
参考文件索引
| File | When to read |
|---|---|
| Before generating an encrypted custom field |
| Before generating org encryption-policy settings (member |
| Before generating key-management settings — Cache-Only, EKM, Data 360 (member |
| When choosing deterministic vs probabilistic, or explaining encrypted-field query behavior |
| When configuring or explaining BYOK / BYOKMS / EKM / Cache-Only key models |
| When the user asks about key rotation, destruction, or BYOK upload |
| To verify a generated Cache-Only key-settings file |
| After generating any settings XML — validates the replay dependency and scheme enum |
| 文件 | 阅读时机 |
|---|---|
| 生成加密自定义字段之前 |
| 生成组织加密策略设置(成员 |
| 生成密钥管理设置——仅缓存密钥、EKM、Data 360(成员 |
| 选择确定性vs概率性加密,或解释加密字段查询行为时 |
| 配置或解释BYOK/BYOKMS/EKM/仅缓存密钥模型时 |
| 用户询问密钥轮换、销毁或BYOK上传时 |
| 验证生成的仅缓存密钥设置文件时 |
| 生成任何设置XML之后——验证重放依赖关系和方案枚举 |