fix: rsa2_sign后备逻辑改为from_pkcs8_der(支持裸Base64私钥)

This commit is contained in:
2026-05-25 14:13:32 +08:00
parent e6e04979dc
commit d5f87d3d85
2 changed files with 8 additions and 8 deletions

View File

@@ -96,9 +96,8 @@ fn rsa2_sign(content: &str, private_key_pem: &str) -> Result<String, String> {
private_key_pem,
)
.map_err(|e| format!("Base64 解码失败: {}", e))?;
let pem_str = String::from_utf8(decoded)
.map_err(|e| format!("PEM 字符串格式错误: {}", e))?;
RsaPrivateKey::from_pkcs8_pem(&pem_str)
// 支付宝密钥工具生成的 Base64 解码后是 PKCS#8 DER不是 PEM 文本
RsaPrivateKey::from_pkcs8_der(&decoded)
.map_err(|e| format!("私钥解析失败: {}", e))?
}
};