From bf28ed8e63276bdd44a010277958045a7e721f40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=AD=90=E9=93=AD?= Date: Wed, 5 Mar 2025 18:18:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/alipay/cert.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/utils/alipay/cert.go b/utils/alipay/cert.go index 02864f7..ae3413a 100644 --- a/utils/alipay/cert.go +++ b/utils/alipay/cert.go @@ -44,34 +44,41 @@ func GetCert(appId string) (*CertConfig, error) { if c != nil { return c, nil } + dir, err := os.Getwd() if err != nil { return nil, fmt.Errorf("get current dir error: %v", err) } + filePath := fmt.Sprintf("%s/%s/%s/%s", dir, "cert", "alipay", appId) if !helper.FileExists(filePath) { - return nil, fmt.Errorf("appId[%s]支付宝密钥文件信息不存在,请联系技术人员处理", appId) + return nil, fmt.Errorf("appId[%s][%s]支付宝密钥文件信息不存在,请联系技术人员处理", appId, filePath) } + mchCertPath := fmt.Sprintf("%s/%s_%s.crt", filePath, "appCertPublicKey", appId) mchCertSN, err := getMchCertSN(mchCertPath) if err != nil { return nil, fmt.Errorf("get mchCertSN error: %v", err) } + rootCertPath := fmt.Sprintf("%s/%s", filePath, "alipayRootCert.crt") rootCertSN, err := getRootCertSN(rootCertPath) if err != nil { return nil, fmt.Errorf("get rootCertSN error: %v", err) } + publicKeyPath := fmt.Sprintf("%s/%s", filePath, "alipayCertPublicKey_RSA2.crt") publicKey, err := getPublicKey(publicKeyPath) if err != nil { return nil, fmt.Errorf("get publicKey error: %v", err) } + c = &CertConfig{ MchCertSN: mchCertSN, RootCertSN: rootCertSN, PublicKey: publicKey, } setCertConfig(appId, c) + return c, nil }