NodeJS: Validate certificate in DER format(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.
有没有办法(或模块)使用 NodeJS 将 DER 转换为 PEM 格式?我找不到任何东西,也无法使用命令行通过 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 格式验证证书的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:NodeJS:以 DER 格式验证证书


基础教程推荐
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01