xiongzhu vor 2 Jahren
Ursprung
Commit
22198e3a7f
1 geänderte Dateien mit 5 neuen und 2 gelöschten Zeilen
  1. 5 2
      src/weixin/weixin.service.ts

+ 5 - 2
src/weixin/weixin.service.ts

@@ -42,7 +42,10 @@ export class WeixinService {
         ApiConfigKit.setCurrentAppId(apiConfig.getAppId)
         this.privateKey = fs.readFileSync(this.weixinConfiguration.certPath + 'apiclient_key.pem')
         this.publicKey = fs.readFileSync(this.weixinConfiguration.certPath + 'apiclient_cert.pem')
-        this.platformPlublicKey = fs.readFileSync(this.weixinConfiguration.certPath + 'platform_cert.pem')
+        if (fs.existsSync(this.weixinConfiguration.certPath + 'platform_cert.pem')) {
+            this.platformPlublicKey = fs.readFileSync(this.weixinConfiguration.certPath + 'platform_cert.pem')
+        }
+        this.getCert()
     }
 
     async getAccessToken(): Promise<AccessToken> {
@@ -183,7 +186,7 @@ export class WeixinService {
             )
             // 保存证书
             fs.writeFileSync(certPath, decrypt)
-
+            this.platformPlublicKey = fs.readFileSync(this.weixinConfiguration.certPath + 'platform_cert.pem')
             return data
         } catch (error) {
             Logger.error(error)