Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

How do you use client certificates when making an HTTPS call from node.js with Apigee Edge

Following the examples I've written my js code and running on my laptop it works fine - HTTPS call is made using client certificate authentication. Running on Apigee though I can't get it working - it just fails with the following exception: "io.apigee.trireme.core.internal.CryptoException: Input data does not contain a key pair".

Below is the options I'm passing to https.request():

    var options = {
        hostname : www.myhost.com,
        port : 443,
        path: '/service/url',
        key: fs.readFileSync(__dirname + '/certs/APIGEE-client-privkey.pem', 'utf-8'),
        passphrase: 'password',
        cert: fs.readFileSync(__dirname + '/certs/APIGEE-client.cer', 'utf-8'),
        method: 'POST',
        rejectUnauthorized: false,
        headers: {
            'Content-Type': 'application/xml',
            'Content-Length': requestData.length
        }
    };

Presumably running in Apigee edge is using a different Crypto library. Does anybody have this working - if so how do you read in the files so they will be accepted?

Thanks

Solved Solved
2 5 17.2K
1 ACCEPTED SOLUTION

Just had the idea of changing the format of the files as I noticed that the node tls library also accepts pfx files. So I converted the files:

 openssl pkcs12 -export -out certificate.pfx -inkey privateKey.key -in certificate.crt

Using the pfx format seems to work ok.

View solution in original post

5 REPLIES 5
Top Solution Authors