fix: rsa2_sign后备逻辑改为from_pkcs8_der(支持裸Base64私钥)
This commit is contained in:
@@ -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))?
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user