docs: 新增证书说明与数据库迁移文档
- 新增 api/certs/README_wechat_cert.md - 新增 api/migrations/README.md - 新增 api/migrations/sync_schema_to_models.sql Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
29
api/certs/README_wechat_cert.md
Normal file
29
api/certs/README_wechat_cert.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# 微信支付 401 签名错误排查
|
||||
|
||||
## 原因
|
||||
|
||||
**WECHAT_PAY_CERT_SERIAL_NO** 必须是「商户 API 证书」的序列号,且该证书与 `apiclient_key.pem`(商户私钥)为一对。
|
||||
若序列号与私钥不对应,微信会返回 401 签名错误。
|
||||
|
||||
## 获取正确序列号
|
||||
|
||||
### 方式一:从商户证书文件读取(推荐)
|
||||
|
||||
若你有 `apiclient_cert.pem`(与 `apiclient_key.pem` 同时从商户平台下载):
|
||||
|
||||
```bash
|
||||
cd api
|
||||
openssl x509 -in certs/apiclient_cert.pem -noout -serial
|
||||
```
|
||||
|
||||
输出示例:`serial=55D97D542DBAA9CB9B7D0ACDB810CC99C208D328`
|
||||
将等号后面的十六进制(可全部大写)填到 `.env` 的 `WECHAT_PAY_CERT_SERIAL_NO`。
|
||||
|
||||
### 方式二:从商户平台查看
|
||||
|
||||
登录 [微信支付商户平台](https://pay.weixin.qq.com) → **账户中心** → **API 安全** → **API 证书** → 查看与当前私钥对应的**证书序列号**,复制到 `WECHAT_PAY_CERT_SERIAL_NO`。
|
||||
|
||||
## 其他可能
|
||||
|
||||
- **私钥与证书不是一对**:重新在商户平台下载 API 证书,使用新的 `apiclient_key.pem` 与证书序列号。
|
||||
- **服务器时间偏差**:与标准时间误差不要超过约 5 分钟。
|
||||
Reference in New Issue
Block a user