【问题标题】:Error Loading extension section v3_req PEM加载扩展部分 v3_req PEM 时出错
【发布时间】:2021-09-18 13:42:06
【问题描述】:

尝试使用库“pem”生成具有 v3_req 扩展名的证书,但我总是遇到错误。 API 文档说如果我指定配置,那么将使用 v3_req 部分。但是现在,它无法加载并显示此错误:

% openssl x509 -req -sha256 -days 1095 -in /tmp/dc4690e0574dfc1e6c1239c0215aed5326041d2e -signkey /tmp/01177dfb1c2748532d5f380144deb30ac61a1e66 -extensions v3_req -extfile /tmp/4e2988602eaded57582aea801ec912dd6ad9b4e1
2021-09-18 14:03:17.443706158 +0200 CEST [web-1] Error Loading extension section v3_req
2021-09-18 14:03:17.443702601 +0200 CEST [web-1] Error: Invalid openssl exit code: 1
2021-09-18 14:03:17.442257164 +0200 CEST [web-1] at Pipe._handle.close (net.js:607:12)
2021-09-18 14:03:17.442253496 +0200 CEST [web-1] at Socket.emit (events.js:198:13)
2021-09-18 14:03:17.442237483 +0200 CEST [web-1] at Socket.stream.socket.on (internal/child_process.js:389:11)
2021-09-18 14:03:17.442237047 +0200 CEST [web-1] at maybeClose (internal/child_process.js:982:16)
2021-09-18 14:03:17.442227991 +0200 CEST [web-1] at ChildProcess.emit (events.js:198:13)
2021-09-18 14:03:17.442227473 +0200 CEST [web-1] at ChildProcess. (/app/node_modules/pem/lib/openssl.js:175:7)
2021-09-18 14:03:17.442214690 +0200 CEST [web-1] at done (/app/node_modules/pem/lib/openssl.js:158:27)
2021-09-18 14:03:17.442212176 +0200 CEST [web-1]
2021-09-18 14:03:17.441976235 +0200 CEST [web-1] Error Loading extension section v3_req

我正在使用这个函数来生成证书:

const cert = await pem.createCertificate({ clientKey: clientPrivateKey, serviceKey: servicePrivateKey, selfSigned: true, extFile:${_dirname}/ext${keyName}.txt, config: {}, csr, days: 1095 });

并加载此文件:

[req]
req_extensions = v3_req
distinguished_name = req_distinguished_name

[req_distinguished_name]
commonName = Common Name
commonName_max = 64

[v3_req]
basicConstraints = critical,CA:TRUE
keyUsage = nonRepudiation, digitalSignature, keyEncipherment

知道为什么会出现此错误吗?

问候

【问题讨论】:

    标签: node.js certificate pem


    【解决方案1】:

    我终于找到了我的错误,我错误地使用了配置参数。正确的做法->

     const cert = await pem.createCertificate({
        clientKey: clientPrivateKey,
        serviceKey: servicePrivateKey,
        selfSigned: true,
        config: [
          '[req]',
          'req_extensions = v3_req',
          'distinguished_name = req_distinguished_name',
          '[req_distinguished_name]',
          'commonName = Common Name',
          'commonName_max = 64',
          '[v3_req]',
          'basicConstraints = critical,CA:TRUE',
          `keyUsage = ${keyUsage}`].join('\n'),
        csr,
        days: 1095
      });
    

    【讨论】:

      猜你喜欢
      • 2014-08-06
      • 1970-01-01
      • 2017-10-10
      • 1970-01-01
      • 2017-10-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-20
      相关资源
      最近更新 更多