代码调整
This commit is contained in:
parent
d9adae9639
commit
bf28ed8e63
|
@ -44,34 +44,41 @@ func GetCert(appId string) (*CertConfig, error) {
|
||||||
if c != nil {
|
if c != nil {
|
||||||
return c, nil
|
return c, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
dir, err := os.Getwd()
|
dir, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("get current dir error: %v", err)
|
return nil, fmt.Errorf("get current dir error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
filePath := fmt.Sprintf("%s/%s/%s/%s", dir, "cert", "alipay", appId)
|
filePath := fmt.Sprintf("%s/%s/%s/%s", dir, "cert", "alipay", appId)
|
||||||
if !helper.FileExists(filePath) {
|
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)
|
mchCertPath := fmt.Sprintf("%s/%s_%s.crt", filePath, "appCertPublicKey", appId)
|
||||||
mchCertSN, err := getMchCertSN(mchCertPath)
|
mchCertSN, err := getMchCertSN(mchCertPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("get mchCertSN error: %v", err)
|
return nil, fmt.Errorf("get mchCertSN error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
rootCertPath := fmt.Sprintf("%s/%s", filePath, "alipayRootCert.crt")
|
rootCertPath := fmt.Sprintf("%s/%s", filePath, "alipayRootCert.crt")
|
||||||
rootCertSN, err := getRootCertSN(rootCertPath)
|
rootCertSN, err := getRootCertSN(rootCertPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("get rootCertSN error: %v", err)
|
return nil, fmt.Errorf("get rootCertSN error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
publicKeyPath := fmt.Sprintf("%s/%s", filePath, "alipayCertPublicKey_RSA2.crt")
|
publicKeyPath := fmt.Sprintf("%s/%s", filePath, "alipayCertPublicKey_RSA2.crt")
|
||||||
publicKey, err := getPublicKey(publicKeyPath)
|
publicKey, err := getPublicKey(publicKeyPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("get publicKey error: %v", err)
|
return nil, fmt.Errorf("get publicKey error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
c = &CertConfig{
|
c = &CertConfig{
|
||||||
MchCertSN: mchCertSN,
|
MchCertSN: mchCertSN,
|
||||||
RootCertSN: rootCertSN,
|
RootCertSN: rootCertSN,
|
||||||
PublicKey: publicKey,
|
PublicKey: publicKey,
|
||||||
}
|
}
|
||||||
setCertConfig(appId, c)
|
setCertConfig(appId, c)
|
||||||
|
|
||||||
return c, nil
|
return c, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue