如何将JKS证书用于NODE https客户端请求 [英] How to use JKS certificate for NODE https client request

查看:402
本文介绍了如何将JKS证书用于NODE https客户端请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用NodeJS应用程序中JKS密钥库中的证书.

I would like to use certificate from a JKS keystore within a NodeJS application.

var fs = require('fs'); 
var https = require('https'); 

var options = { 
  hostname: 'XXX.com', 
  port: 4443, 
  path: '/endpoint', 
  method: 'GET', 
  key: fs.readFileSync('private.pem'), 
  cert: fs.readFileSync('public.pem'), 
};


var req = https.request(options, function(res) { 
  res.on('data', function(data) { 
    process.stdout.write(data); 
  }); 
}); 

req.end(); 

req.on('error', function(e) { 
  console.error(e); 
});

如何将JKS转换为PEM? 谢谢

How can i convert the JKS to PEM ? Thank you

推荐答案

如何将JKS证书用于NODE https客户端请求

How to use JKS certificate for NODE https client request

我不知道有没有办法做到这一点.但是...

I don't know if there's a way to do that. But...

如何将JKS转换为PEM?

How can i convert the JKS to PEM ?

肯定有一种方法:

$ keytool -importkeystore -srckeystore keystore.jks -destkeystore keystore.p12
-deststoretype PKCS12 -srcalias <jkskeyalias> -deststorepass <password>
-destkeypass <password>
$ openssl pkcs12 -in keystore.p12  -nokeys -out public.pem
$ openssl pkcs12 -in keystore.p12  -nodes -nocerts -out private.pem

这篇关于如何将JKS证书用于NODE https客户端请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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