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);
});
How can i convert the JKS to PEM ? Thank you
How to use JKS certificate for NODE https client request
I don't know if there's a way to do that. But...
How can i convert the JKS to PEM ?
There is definitely a way to do that:
$ 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
来源:https://stackoverflow.com/questions/50656756/how-to-use-jks-certificate-for-node-https-client-request