James Thomas
James Thomas

Reputation: 4339

Pitney Bownes Location API from NodeJS -> [Error: UNABLE_TO_VERIFY_LEAF_SIGNATURE]

I'm trying to send the access the Pitney Bownes Reverse-Geolocation API using the Request Module in NodeJS.

Sending the following HTTP request returns an error.

request("https://pitneybowes.pbondemand.com/location/address/lookup.json?latitude=LAT&longitude=LONG&searchDistance=1000&appId=APP_ID", function (err, res, body) {});

[Error: UNABLE_TO_VERIFY_LEAF_SIGNATURE]

Hitting this same URL in my browser returns the JSON response expected.

What's going wrong with the request sent from the NodeJS platform?

Upvotes: 0

Views: 246

Answers (2)

Jay Allen
Jay Allen

Reputation: 21

Jeff is right about the SSL certificate. An alternative is to set

process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";

Here's the source to a picture finder app in IBM DevOps services that shows the fix. https://hub.jazz.net/project/jstart/Picture%20Finder%20(Node)/overview#https://hub.jazz.net/git/jstart%252FPicture.Finder.%2528Node%2529/contents/master/app/app.js

Upvotes: 2

James Thomas
James Thomas

Reputation: 4339

Looking at the server's certificate CA, there's an issue with the intermediate SSL certificate not being properly configured.

We can modify the request call to include a property to ignore this error at runtime.

request({
  url: url,
  rejectUnauthorized: false
})

The external service provider has verified this issue exists within their API and provided an alternative solution that involves importing the certificates on your local system.

Upvotes: 3

Related Questions