【问题标题】:How to create a Certificate Authority 'CA' using pem lib NodeJs?如何使用 pem lib NodeJs 创建证书颁发机构“CA”?
【发布时间】:2019-11-01 02:43:35
【问题描述】:

使用节点创建 CA

这是使用 OpenSSL 创建证书的方法 OpenSSL Certificate Authority

我试过pem

这是我关闭的问题can't create CSR from private key #244 GitHub

当我尝试生成 CSR

var csrOptions = {
    clientKey: '/root/ca/intermediate/private/client.key.pem',
    clientKeyPassword: '123456',
    hash: 'sha256',
    country: 'US',
    state: 'California',
    locality: 'Mountain View',
    organization: 'Alice Ltd',
    organizationUnit: 'Alice Ltd Web Services',
    commonName: 'pass:client',
}

pem.createCSR( csrOptions , function(err, csr) {
    if (err) {
        throw err
    } else {
        console.log(csr.clientKey)
        console.log(csr.csr)
    }

});

我收到此错误

/root/sslnode/index2.js:37

抛出错误 ^

% openssl req -new -sha256 -config /root/ca/intermediate/openssl.cnf -key /tmp/54f976cb9cbd0e2dd53b755badb6e6e3fe2256ad -passin 文件:/tmp/3f4640f1d95ca955f1c44c7f2c4b729347813a5f

无法加载私钥 140563986715072:error:0906D06C:PEM 例程:PEM_read_bio:no start >line:../crypto/pem/pem_lib.c:691:Expecting: ANY PRIVATE KEY

【问题讨论】:

    标签: node.js certificate-authority


    【解决方案1】:

    搜索后出现错误,clientKey 将键作为字符串,而不是路径

    clientKey: '/root/ca/intermediate/private/client.key.pem',

    clientKey: fs.readFileSync('/root/ca/intermediate/private/client.key.pem'),
    

    【讨论】:

      猜你喜欢
      • 2013-05-02
      • 2012-10-31
      • 2014-12-26
      • 2015-05-30
      • 1970-01-01
      • 1970-01-01
      • 2018-03-28
      • 1970-01-01
      相关资源
      最近更新 更多