We are trying to implement ApplePay on the web in my project. As per apple documentation i am getting the validation url from applejs api onvalidatemerchant function and i am passing this validation url to a node js route to get the apple payment session. This is the documentation i am following to get the apple payment session(<https://developer.apple.com/documentation/apple_pay_on_the_web/apple_pay_js_api/requesting_an_apple_pay_payment_session>).

The below is the custom node js code i have written to get the apple payment session. The validation url ie)req.query.url passed to this node js route code is <https://apple-pay-gateway-cert.apple.com/paymentservices/startSession>.

```
app.get('/getAppleSession2', function (req, res) {

  var endpointURL = req.query.url;
  var cert_path = './apple_pay.pem';
  var cert = fs.readFileSync(cert_path);
  console.log('endpointURL is ' + endpointURL);
  console.log('cert_path is ' + cert_path);
  console.log('cert is'+cert);
  const options = {
    url: endpointURL,
    method: 'post',
    cert: cert,
    key: cert,
    body: {
      merchantIdentifier: "xxxxx.xxxxx.xxxxx.xxxxx.xxxxx",
      displayName: "xxxxx.xxxxx.xxxxx.xxxxx.xxxxx",
      initiative: "web",
      initiativeContext: "xxxxx.xxxx.xxxx.xxxx.com"
    },
    json: true,
  };
  //console.log("body" + body);
  request(options, function (error, response, body) {
    console.log('body of  getAppleSession' + body);
    console.log('Response from getAppleSession' + response);
    console.error('Error object ' + error);

    res.send(body);
  });

});

```

But this is the response i am getting for this route 

```
body of  getAppleSession undefined
Response from getAppleSession undefined
Error object Error: error:0906D06C:PEM routines:PEM_read_bio:no start line

```

Not sure what is wrong here as i am doing this as per apple's documentation. I suspect if it has anything to do with how i am passing the certs(Merchant Identity certificate)to this nodejs route. I generated the certificate by downloading the Merchant Identity certificate in .cer format from Apple Development portal and converted the certificate i downloaded from Apple portal to .pem format by importing the .cer file in KeyChain access in my mac and exporting it to .pem in keychain access. I then placed the .pem file('./apple\_pay.pem') in same directory of my node js route. Is there anything wrong in how i am generating the certificates or passing them in my node js route?

Not sure what is wrong here. Any code sample or pointers will be really helpful.