I am trying to use SSL secured api which Two Way SSL Authentication. Have already created self signed certificate using keytool -genkey command and created 3 key files (selfsigned.crt , selfsigned.p12, selfsigned.jks) which is shared with API provider. and one UATSKY.crt certificate given by API provider is added to my trust store on mac. now when i try to access this api from post man it gives me pop up to select certificate after which it makes successful call api and get positive response.how do i achieve same in Node JS application.
I tried using https.createserver and passing ptivate key and certificate to the craeteserver
var app = express();
app.use(bodyParser.urlencoded({
extended: false
}));
app.use(bodyParser.json());
app.use(bodyParser.json({ limit: '50mb' }));
app.use(bodyParser.urlencoded({ limit: '50mb', extended: true }));
app.use(cors());
var privateKey =
fs.readFileSync('./private/selfsignedpayeazzy.p12');
var certificate = fs.readFileSync('./private/selfsignedpayeazzy.crt');
var credentials = {
key: privateKey,
cert: certificate
};
https.createServer(credentials, app).listen(port);
This is gives me following error
_tls_common.js:112
c.context.setCert(cert);
^
Error: error:0906D06C:PEM routines:PEM_read_bio:no start line
at Object.createSecureContext (_tls_common.js:112:17)
at Server.setSecureContext (_tls_wrap.js:960:27)
at Server (_tls_wrap.js:850:8)
at new Server (https.js:61:14)
at Object.createServer (https.js:83:10)
not able to add this certificates to the application.