6

I'm very sorry for my language but I'm not speak english.

I'm trying to implement in my app SSL but I have only valud p7b created by csr file. I'm using expressjs and node js on linux server. I know how to implement 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 don't know how implement p7b certificate, kindly help me

axlpl
  • 483
  • 1
  • 7
  • 18

1 Answers1

0

First you have to conver your p7b to pem format:

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

Create a pkcs12 file contiaing your private key and the public certificate:

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

To use the pfx file with node js use

const cert = fs.readFileSync("result.pfx");
const request = require('request').defaults({
    agentOptions: {
        pfx: cert,
        passphrase: password
    }
});
gnom1gnom
  • 735
  • 7
  • 15