NodeJS:以DER格式验证证书 [英] NodeJS: Validate certificate in DER format

查看:1321
本文介绍了NodeJS:以DER格式验证证书的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 crypto 模块验证证书,但我的证书和我的公钥都是 DER 格式。看来 crypto 模块不接受此格式。

I'm using crypto module to validate a certificate, but both, my certificate and my public key are in DER format. It seems that crypto module does not accept this format.

有一种方法到PEM格式使用NodeJS?我找不到任何内容,无法使用命令行通过shell调用 openssl

Is there a way (or module) to convert DER to PEM format using NodeJS? I couldn't find any and cannot use command line to call openssl via shell.

更新:关于HTTPS证书。它是关于一般X.509证书。如果您将问题标记为否定,请发表评论以证明其正确性。

UPDATE: It's not about HTTPS certificates. It's about general X.509 certificates. And if you mark the question as negative, please leave a comment to justify it. Don't be a stupid if you are not able to help.

推荐答案

Dominykas的回答很好,但在我的例子中,我有一个证书,使用 ECC node-forge 不支持它。
所以我找到一个名为 node- openssl-wrapper ,它工作得很好,因为它在一个简单的函数调用中封装了openssl命令,如下所示:

Dominykas' answer was good, but in my case, I have a certificate that uses ECC and node-forge does not support it. So I've found a module called node-openssl-wrapper, which worked perfectly well because it encapsulates the openssl commands in a simple function call, like this:

co(function*() {
  var ossl = require('openssl-wrapper');
  var derCert = new Buffer('...'); // binary DER certificate
  var pemCert = yield ossl.qExec('x509', derCert, { inform: 'der', outform: 'pem' });
});

这篇关于NodeJS:以DER格式验证证书的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆