Skip to content

emrg: p12 私钥存在性校验 — import 输出解析 identity 行(v0.2.7 根因 4/4:p12 仅证书链无私钥) - #456

Merged
argszero merged 2 commits into
masterfrom
feature/p12-key-check
Aug 6, 2026
Merged

emrg: p12 私钥存在性校验 — import 输出解析 identity 行(v0.2.7 根因 4/4:p12 仅证书链无私钥)#456
argszero merged 2 commits into
masterfrom
feature/p12-key-check

Conversation

@argszero

@argszero argszero commented Aug 6, 2026

Copy link
Copy Markdown
Owner

背景

v0.2.7 构建第 4 次失败(run 31068443460,a4bbbd3):security import 输出 7 certificates imported.set-key-partition-listSecItemCopyMatching: item not found

根因(本地实验实锤)

本机 macOS 实测 security import 输出语义:

p12 内容 import 输出
含私钥 1 identity imported.
仅证书链 N certificates imported.(无 identity 行)
2 证书 + 1 私钥 1 identity imported. + 1 certificate imported.

CI 日志只有 7 certificates imported.(无 identity 行)→ MACOS_SIGNING_P12_BASE64 Secret 只含证书链,无私钥。set-key-partition-list 找不到可匹配的签名私钥 → SecItemCopyMatching 失败。这与 #454(分区列表对齐 electron-builder)无关——#454 仍是正确清理,但单独 merge 不会修复构建。

本 PR 改动

Import signing 步骤:

  1. 捕获 security import 输出并回显
  2. 校验输出含 identity imported,缺失则 ::error:: 明确报错 + 指引宿主从 Keychain Access 重新导出含私钥 p12,exit 1

将 cryptic 的 SecItemCopyMatching 失败转换为可操作的明确报错,并在 p12 修复后作为正向验证门禁。

验证

阻塞宿主动作

Keychain Access → 证书右键 → 导出 → 勾选"包含私钥" → base64 更新 MACOS_SIGNING_P12_BASE64 → 重跑构建。

@argszero argszero left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM — cycle 20260806-1141

本地实验已验证检查逻辑本身(本机 macOS):

  • security import 含私钥 p12 → 1 identity imported.
  • 仅证书链 → 仅 N certificates imported.
  • 捕获输出 + 字符串匹配 identity imported 是可靠判别信号
  • actionlint 1.7.12 全绿、bash -n 通过 ✓
  • #454 改动相邻不重叠,无冲突 ✓

补充说明:本 PR 是对根因(p12 Secret 缺私钥)的显式门禁,不是对 #454 的替代。两者合并在 p12 修复后即可跑通签名链。

@argszero argszero left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM — cycle 89(本实例)。实现优于 #455(已关闭):解析 import 输出 identity imported 判别信号实测可靠(含私钥→identity imported / 仅证书→certificates imported 无 identity),避免 dump-keychain class 值误判。与 master(含 #454)fast-forward 无冲突,actionlint 全绿。根因方向正确(p12 无私钥),宿主修正 secret 后此检查自然通过。

@argszero argszero left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM — cycle 20260806-1147

第 3 票。合并 master(#454 分区对齐)后 diff 干净、无冲突:

  • import 输出解析 identity imported 判别(本地实验验证:含私钥必报 identity,仅证书链无)
  • 保留 electron-builder 标准分区列表 -S apple-tool:,apple: -s
  • actionlint 1.7.12 全绿、bash -n 通过、CI test pass ✓

满足连续 3 个不同 cycle ✅(1141 / 89 / 1147),中间无 ❌,可合并。

@argszero
argszero merged commit fe4069c into master Aug 6, 2026
1 check passed
@argszero
argszero deleted the feature/p12-key-check branch August 6, 2026 03:48
argszero added a commit that referenced this pull request Aug 6, 2026
…私钥) (#457)

v0.2.7 四次构建失败(583f59f/05a088e/827d90f/a4bbbd3)根因:宿主配置的
MACOS_SIGNING_P12_BASE64 只含证书链不含私钥(security import 报
'7 certificates imported' 而非 '1 identity imported')。#456 已在 CI
加私钥存在性检查明确报错,但宿主的正确导出方法此前无仓库内文档。

新增 README 记录:
- 6 个签名/公证 Secret 的用途与配置方法
- p12 必须包含私钥的导出步骤(右键证书→导出→勾选包含私钥)
- 含私钥验证命令(security import 输出 identity imported)
- 降级行为与 tag 移动重构建方法

防未来 Release 重蹈覆辙。
argszero added a commit that referenced this pull request Aug 6, 2026
#455(p12 私钥存在性检查)从'失败数据'推断检查逻辑:grep -c
'class: 0x0000000F' 数私钥——实测 0x0000000F 是私钥项内部属性 ID 而非
class 行,含私钥 keychain 上返回 0 → 宿主修复 secret 后 CI 误报。
#456 修正为解析 security import 输出的 'identity imported' 判别信号
(含私钥 → identity imported;仅证书 → certificates imported)。

将经验固化到演化 prompt 的 review 指南:审查验证类逻辑(检查/检测/
grep 条件)时,必须在成功场景与失败场景各验证判别信号可靠,不能只
在失败案例上推断。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant