I'm currently working on a application that requires getting data from a REST endpoint located in a encrypted network. To access the data in the network I need to either be physically there (currently not possible) or use a PEM certificate provided to me to access the data in the network.
I'm using node as the back-end for my application and AngularJS for the front end.
My HTTPS requests are being done in the front end using restangular since I only need to read data from a REST endpoint located at the encrypted network.
tl;dr
My questions is: How can I use a pem certificate to do an HTTPS POST request using angular/restangular? Previously on PHP what I did was invoke curl, but that works different from what I'm discussing above. I used PHP like this a long time ago:
function request($endpoint){
$cert = 'certificate.pem';
$curl = curl_init();
$options = array(
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_FOLLOWLOCATION => 1,
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_SSL_VERIFYPEER => 0,
CURLOPT_URL => $endpoint,
CURLOPT_SSLCERT => $cert,
CURLOPT_SSLCERTPASSWD => $_SESSION['...'] ,
);
curl_setopt_array($curl , $options);
return curl_exec($curl);
}
You'd have to do it on the backend because that kind of functionality doesn't really exist on the frontend.
If that backend is node, then you simply use https.request() and with the key
, cert
, and ca
(or just pfx
) properties set appropriately.