nodejs with expressjs and SSL p7b certificate
Asked Answered
P

1

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

Propagandism answered 11/3, 2016 at 9:55 Comment(3)
did you ever get your answer? I am running into the same issue...Gove
do you ever find any solution ?Govern
Slightly off topic here. If there's no solution, how about implementing SSL on the server networking settings? Like on ubuntu with apache2 + lets encrypt SSL cert (free).Noisemaker
R
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
    }
});
Rance answered 18/1, 2019 at 8:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.