Nodejs with expressjs and p7b SSL certificate

I am very sorry for my language, but I do not speak English.

I am trying to implement SSL in my application, but I only have valud p7b created by the csr file. I am using expressjs and node js on linux server. I know how to implement a PEM certificate

var options = { key: fs.readFileSync('./private.pem'), cert: fs.readFileSync('./' + config.ssl[config.mode].cert) }; server = https.createServer(options, app).listen(3000); 

but i dont know how to implement p7b certificate, kindly help me

+5
source share
1 answer

First you need to convert your p7b to pem format:

 openssl pkcs7 -in public.p7b -inform DER -out public.pem -print_certs 

Create a pkcs12 file containing your private key and public certificate:

 openssl pkcs12 -export -inkey private.key -in public.pem -name my_name -out result.pfx 

To use pfx file with js node use

 const cert = fs.readFileSync("result.pfx"); const request = require('request').defaults({ agentOptions: { pfx: cert, passphrase: password } }); 
0
source

Source: https://habr.com/ru/post/1244872/


All Articles