收藏
回答

企业转账到零钱遇到p12证书文件的Unsupported PKCS12 PFX data不支持问题?

后端调用:let result = await api.transfers({

            partner_trade_no: no,

            openid: openid,

            //re_user_name: userName,

            amount: price * 100,

            check_name: "NO_CHECK",

            desc: '提现'

        });

出现异常:

nodejs.ERR_CRYPTO_UNSUPPORTED_OPERATIONError: Unsupported PKCS12 PFX data, POST https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers -1 (connected: false, keepalive socket: false, socketHandledRequests: 0, socketHandledResponses: 0

pfx配置在下面

pfx: require('fs').readFileSync('app/public/cert/apiclient_cert.p12'),

目前的问题是p12文件的加密方式sha1在
 at configSecureContext (node:internal/tls/secure-context:290:15)
    at Object.createSecureContext (node:_tls_common:114:3)
    at Object.connect (node:_tls_wrap:1764:48)
    at Agent.createConnection (node:https:173:22)
    at Agent.createSocket (node:_http_agent:330:26)
    at Agent.addRequest (node:_http_agent:278:10)
    at new ClientRequest (node:_http_client:340:16)
    at Object.request (node:https:381:10)
    at Object.requestWithCallback (D:\workspace-vscode\qingyalive\node_modules\urllib\lib\urllib.js:1051:19)
    at D:\workspace-vscode\qingyalive\node_modules\urllib\lib\urllib.js:162:13
    at new Promise (<anonymous>)
中不支持,nodejs从10.0版本就不支持p12文件的加密方式sha1,我们的服务器对nodejs版本的要求在10.0以上。

具体异常情况在下面:

2024-12-24 16:56:09,668 ERROR 76256 [-/127.0.0.1/-/26648ms POST /api/gift/wxTransfer] nodejs.ERR_CRYPTO_UNSUPPORTED_OPERATIONError: Unsupported PKCS12 PFX data, POST https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers -1 (connected: false, keepalive socket: false, socketHandledRequests: 0, socketHandledResponses: 0)

headers: {}

headers: {}

    at configSecureContext (node:internal/tls/secure-context:290:15)

    at Object.createSecureContext (node:_tls_common:114:3)

    at Object.connect (node:_tls_wrap:1764:48)

    at Agent.createConnection (node:https:173:22)

    at Agent.createSocket (node:_http_agent:330:26)

    at Agent.addRequest (node:_http_agent:278:10)

    at new ClientRequest (node:_http_client:340:16)

    at Object.request (node:https:381:10)

    at Object.requestWithCallback (D:\workspace-vscode\qingyalive\node_modules\urllib\lib\urllib.js:1051:19)

    at D:\workspace-vscode\qingyalive\node_modules\urllib\lib\urllib.js:162:13

    at new Promise (<anonymous>)

    at Object.request (D:\workspace-vscode\qingyalive\node_modules\urllib\lib\urllib.js:161:10)

    at Payment._request (D:\workspace-vscode\qingyalive\node_modules\tenpay\lib\index.js:195:39)

    at Payment.transfers (D:\workspace-vscode\qingyalive\node_modules\tenpay\lib\index.js:543:17)

    at GiftController.wxTransfer (D:\workspace-vscode\qingyalive\app\controller\api\gift.js:179:32)

    at async D:\workspace-vscode\qingyalive\app\middleware\error_handler.js:4:13

    at async D:\workspace-vscode\qingyalive\node_modules\egg-development\app\middleware\egg_loader_trace.js:9:50      

    at async xframe (D:\workspace-vscode\qingyalive\node_modules\egg-security\lib\middlewares\xframe.js:7:5)

    at async xssProtection (D:\workspace-vscode\qingyalive\node_modules\egg-security\lib\middlewares\xssProtection.js:7:5)

    at async nosniff (D:\workspace-vscode\qingyalive\node_modules\egg-security\lib\middlewares\nosniff.js:8:5)        

    at async noopen (D:\workspace-vscode\qingyalive\node_modules\egg-security\lib\middlewares\noopen.js:8:5)

    at async session (D:\workspace-vscode\qingyalive\node_modules\koa-session\index.js:41:7)

code: "ERR_CRYPTO_UNSUPPORTED_OPERATION"

data: undefined

path: "/mmpaymkttransfers/promotion/transfers"

status: -1

headers: {}

res: {"status":-1,"statusCode":-1,"statusMessage":null,"headers":{},"size":0,"aborted":false,"rt":5,"keepAliveSocket":false,"requestUrls":["https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers"],"timing":null,"remoteAddress":"","remotePort":"","socketHandledRequests":0,"socketHandledResponses":0}

name: "ERR_CRYPTO_UNSUPPORTED_OPERATIONError"

pid: 76256

hostname: DESKTOP-ISEJQB8


2024-12-24 16:56:13,632 ERROR 76256 [-/127.0.0.1/-/30614ms POST /api/gift/wxTransfer] nodejs.AssertionError: invalid status code: -1

    at set status (D:\workspace-vscode\qingyalive\node_modules\koa\lib\response.js:88:5)

    at Object.status (D:\workspace-vscode\qingyalive\node_modules\delegates\index.js:92:31)

    at D:\workspace-vscode\qingyalive\app\middleware\error_handler.js:40:24

    at async D:\workspace-vscode\qingyalive\node_modules\egg-development\app\middleware\egg_loader_trace.js:9:50      

    at async xframe (D:\workspace-vscode\qingyalive\node_modules\egg-security\lib\middlewares\xframe.js:7:5)

    at async xssProtection (D:\workspace-vscode\qingyalive\node_modules\egg-security\lib\middlewares\xssProtection.js:7:5)

    at async nosniff (D:\workspace-vscode\qingyalive\node_modules\egg-security\lib\middlewares\nosniff.js:8:5)        

    at async noopen (D:\workspace-vscode\qingyalive\node_modules\egg-security\lib\middlewares\noopen.js:8:5)

    at async session (D:\workspace-vscode\qingyalive\node_modules\koa-session\index.js:41:7)

    at async bodyParser (D:\workspace-vscode\qingyalive\node_modules\koa-bodyparser\index.js:78:5)

    at async D:\workspace-vscode\qingyalive\node_modules\koa-static-cache\index.js:39:63

    at async notfound (D:\workspace-vscode\qingyalive\node_modules\egg\app\middleware\notfound.js:5:5)

    at async meta (D:\workspace-vscode\qingyalive\node_modules\egg\app\middleware\meta.js:18:5)

    at async cors (D:\workspace-vscode\qingyalive\node_modules\@koa\cors\index.js:61:32)

    at async D:\workspace-vscode\qingyalive\node_modules\koa\lib\application.js:160:16

generatedMessage: false

code: "ERR_ASSERTION"

actual: false

expected: true

operator: "=="

pid: 76256

hostname: DESKTOP-ISEJQB8

回答关注问题邀请回答
收藏

1 个回答

  • Memory
    Memory
    2024-12-24

    为啥非要用P12呢?

    2024-12-24
    有用
    回复 22
    • 向阳花
      向阳花
      2024-12-24
      其他也不行,错得更离谱
      2024-12-24
      回复
    • 向阳花
      向阳花
      2024-12-24
      就p12,pem,key_pem
      2024-12-24
      回复
    • 向阳花
      向阳花
      2024-12-24
      那怎么办,如果不传p12用什么
      2024-12-24
      回复
    • 向阳花
      向阳花
      2024-12-24
      其他两个文件,也报错
      2024-12-24
      回复
    • Memory
      Memory
      2024-12-24回复向阳花
      P12通过openssl3转换一下就就可以用
      2024-12-24
      回复
    查看更多(17)
登录 后发表内容