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 格式验证证书


- Flexslider 箭头未正确显示 2022-01-01
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01
- 失败的 Canvas 360 jquery 插件 2022-01-01
- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01
- addEventListener 在 IE 11 中不起作用 2022-01-01
- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01
- Fetch API 如何获取响应体? 2022-01-01
- 400或500级别的HTTP响应 2022-01-01
- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06