Files
hermes d942da1639
Docker Build / Build and Push Docker Image (push) Failing after 8s
Docker Build / Deploy to Server (push) Skipped
fix(protect): 修「驱动签名打包」这类 pfx 解析失败:81 套身份全部可用
用户上传真实的驱动签名打包 pfx(81 把私钥 / 79 张证书),界面只报「解析失败」。
根因不是口令,是 go-pkcs12 一遇到不认识的 bag 属性就整包报错,而 Windows
导出的 pfx 一定带私有属性(本例 OID 1.3.6.1.4.1.311.17.3.75)。

1) 本地改造 go-pkcs12(third_party/go-pkcs12 + go.mod replace)
   未知属性改为跳过,等价于 openssl 的行为。不认识的属性不影响证书与私钥。
2) 解析失败不再是一句话:新增 PFXError{Reason,Hint,Detail},按魔数判断文件
   到底是什么(pfx / pem / pkcs7 / der 证书 / der 私钥 / 压缩包),并把
   「口令错」和「结构不对」分开判——否则「只有证书的 pfx」会被说成口令错,
   用户改口令永远改不好。口令候选会试 原值 / 去首尾空白 / 空串。
   顺带支持 PEM(证书+未加密私钥)直接上传。
3) 大包不再拆成 N 条记录:79 套就建 79 条记录没法用。改为一条记录 +
   记下身份数,新增 GET /dev/sign-profiles/:id/identities 列全部身份,
   加壳时用 cert_identity 指定第几套,签名那一刻才把那一套单独拆出来
   (LoadMaterial 支持 identity,osslsigncode 只认文件里第一套)。
4) 前端:选中多身份证书时出现「签名身份」可搜索下拉(#序号 · CN · 到期,
   过期标黄),默认第一套;证书下拉标注「N 套身份」。
5) cmd/pfxprobe:本地诊断工具,秒看文件形态/证书数/私钥数/每套到期。

实测(用户真实文件,口令 123456):
- 解析:79 张证书 / 81 把私钥 / 79 套身份(2 把私钥没有配对证书)
- 身份列表接口返回 79 条,含 NVIDIA Corporation / Take-Two 等
- 选第 43 套(NVIDIA)签名 → osslsigncode verify 产物 Subject 为
  CN=NVIDIA Corporation,与面板所选一致
- 前后失败对照:改前「unknown attribute with OID 1.3.6.1.4.1.311.17.3.75」
2026-11-22 12:03:02 +08:00
..

package pkcs12

Documentation

import "software.sslmate.com/src/go-pkcs12" 

Package pkcs12 implements some of PKCS#12 (also known as P12 or PFX). It is intended for decoding DER-encoded P12/PFX files for use with the crypto/tls package, and for encoding P12/PFX files for use by legacy applications which do not support newer formats. Since PKCS#12 uses weak encryption primitives, it SHOULD NOT be used for new applications.

Note that only DER-encoded PKCS#12 files are supported, even though PKCS#12 allows BER encoding. This is because encoding/asn1 only supports DER.

This package is forked from golang.org/x/crypto/pkcs12, which is frozen. The implementation is distilled from https://tools.ietf.org/html/rfc7292 and referenced documents.

Import Path

Note that although the source code and issue tracker for this package are hosted on GitHub, the import path is:

software.sslmate.com/src/go-pkcs12 

Please be sure to use this path when you go get and import this package.

Report Issues / Send Patches

Open an issue or PR at https://github.com/SSLMate/go-pkcs12