What is the process for integrating a third party API certificate into my Heroku application?

When my backend service calls a third-party API (Kamer van koophandel) to retrieve data, it requires a certificate to be set. It functions correctly locally, but upon pushing to Heroku, the following error occurs:

Warning: Ignoring extra certs from `Private_G1_chain.pem`, load failed: error:02001002:system library:fopen:No such file or directory
   Warning: Ignoring extra certs from `Private_G1_chain.pem`, load failed: error:02001002:system library:fopen:No such file or directory
   Warning: Ignoring extra certs from `Private_G1_chain.pem`, load failed: error:02001002:system library:fopen:No such file or directory
   Warning: Ignoring extra certs from `Private_G1_chain.pem`, load failed: error:02001002:system library:fopen:No such file or directory
   gyp: Call to 'node -p "require('node-addon-api').include"' returned exit status 0 while in binding.gyp. while trying to load binding.gyp
   gyp ERR! configure error 
   gyp ERR! stack Error: `gyp` failed with exit code: 1
   gyp ERR! stack     at ChildProcess.onCpExit (/tmp/build_e15be358/.heroku/node/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16)
   gyp ERR! stack     at ChildProcess.emit (events.js:376:20)
   gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
   gyp ERR! System Linux 4.4.0-1088-aws
   gyp ERR! command "/tmp/build_e15be358/.heroku/node/bin/node" "/tmp/build_e15be358/.heroku/node/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/tmp/build_e15be358/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node" "--module_name=bcrypt_lib" "--module_path=/tmp/build_e15be358/node_modules/bcrypt/lib/binding/napi-v3" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=3" "--node_napi_label=napi-v3"
   gyp ERR! cwd /tmp/build_e15be358/node_modules/bcrypt
   gyp ERR! node -v v14.17.0
   gyp ERR! node-gyp -v v5.1.0
   gyp ERR! not ok 
   node-pre-gyp ERR! build error 
   node-pre-gyp ERR! stack Error: Failed to execute '/tmp/build_e15be358/.heroku/node/bin/node /tmp/build_e15be358/.heroku/node/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/tmp/build_e15be358/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node --module_name=bcrypt_lib --

I have set the correct config var in Heroku: NODE_EXTRA_CA_CERTS = Private_G1_chain.pem

Interestingly, if I push my application to Heroku first and then set NODE_EXTRA_CA_CERTS, it works. However, if NODE_EXTRA_CA_CERTS is set before the push, I encounter the above error.

Just for reference, my application is built with node/express and uses typescript.

Thank you for your help!

Answer №1

The error message Ignoring extra certs occurs when Node receives multiple certificates from your .pem file. To fix this issue, remove any white spaces and line breaks from your .pem file.

Follow these steps to resolve the problem:

awk 'NF {sub(/\r/, ""); printf "%s\n",$0;}' your-cert.pem

Execute this command in the directory where your certificate file is located. It will add \n where needed.

The output will look like this:

-----BEGIN RSA PRIVATE KEY-----\njlQvt9WdR9Vpg3WQT5+C3HU17bUOwvhp/r0+viMcBUCRW85UqI2BJJKTi1IwQQ4c\ntyTrhYJYOP+A6JXt5BzDzZy/B7tjEMDBosPiwH2m4MaP+6wTbi1qR1pFDL3fXYDr\n

Save this string in the .env file and use it as a parameter instead of the file Private_G1_chain.pem.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Requesting data using EmberJS

I’m currently developing an app using a combination of MongoDB, Ember, Express, and Node. Below is the structure of my grade model: export default DS.Model.extend({ mark: DS.attr(), section: DS.attr(), student: DS.belongsTo('student&ap ...

Learn the connection and interaction dynamics among node.js, Angular, Express, and MongoDB

I'm currently delving into understanding communication within a MEAN stack. I've created the following code snippets by utilizing the Yeoman fullstack generator for scaffolding the application: Defined mongoose schema 'use strict'; ...

What kind of function possesses additional attributes or characteristics?

I am finding it difficult to define the type for the function foo as demonstrated below: function foo() { do something } foo.boo = () => { do something else } foo("hello"); foo.boo("hello"); This JavaScript code is functioning corr ...

A guide to integrating a component into another component in Angular

Currently, I am encountering an issue with importing a component into another in my Ionic 5.0.0 application. Within my application, I have two separate modules: ChatPageModule and HomePageModule. My objective is to include the Chat template within the Hom ...

Create generic functions that prioritize overloading with the first generic type that is not included in the parameters

I encountered an issue while utilizing generic overload functions, as demonstrated below in the playground. The generic type T1 is solely used in the return type and not the parameters. Therefore, when attempting to use overload #2, I am required to speci ...

The aspect ratio of Threejs sprites is appearing distorted

I'm facing an issue with rendering two objects in an Orthographic camera using Three.js. The objects are not rendering correctly and I'm unsure of the reason behind it. The expected look of the two images is as follows: https://i.sstatic.net/hQ ...

The MongoDB .push operation is returning a null value

Take a look at the GitHub repository where I am actively working: https://github.com/Stick-z/first-media-app I'm currently in the process of creating a website and focusing on the backend development. One of my tasks involves setting up a jokes array ...

What is the best way to choose a particular radio button from a group of radio buttons using typescript?

Is there a way to automatically select a specific radio button when an item is chosen from a dropdown menu on the webpage using a TypeScript function that is triggered by the dropdown selection? ...

What's the best way to implement asynchronous state updating in React and Redux?

In my React incremental-style game, I have a setInterval function set up in App.ts: useEffect(() => { const loop = setInterval(() => { if (runStatus) { setTime(time + 1); } }, rate); return () => clearInterval(lo ...

The server is responding with a 400 error code when a body is included in a

Question: I am experiencing an issue with my Express GET route that fetches all users. Each time a req.body is present, the server consistently returns a response code of 400. I am using body-parser, but this problem only occurs in the production k8s envi ...

Typedoc Error: Attempted to assign a value to an undefined option (mode)

After installing typedoc with the command npm install typedoc --save-dev, I proceeded to add typedocOptions to tsconfig.json: { "compileOnSave": false, "compilerOptions": { "baseUrl": "./", // ...some lin ...

Ensuring that a date is within a certain format in TypeScript

Can someone help me verify the validity of different date formats? I attempted the following method: let newdate = new Date(myStringDate); Date.parse(myStringDate) result = `${newdate.getDate()}/${newdate.getMonth() + 1}/${newdate.getFullYear()}` The re ...

Enhancing the NextPage Typescript Type: A Step-by-Step Guide

I'm working on a NextJS dashboard with role-based access control and I need to pass an auth object to each page from the default export. Here's an image showing an example of code for the Student Dashboard Home Page: Code Example of Student Dashb ...

Execute the authenticate method on every router within the express framework

I just started learning about node.js. I am interested in implementing custom authentication using passport.js on all routers. For reference, I found an example at -> https://github.com/passport/express-4.x-http-bearer-example The code snippet below ...

Ensuring uniqueness in an array using Typescript: allowing only one instance of a value

Is there a simple method to restrict an array to only contain one true value? For instance, if I have the following types: array: { value: boolean; label: string; }[]; I want to make sure that within this array, only one value can be set to t ...

Issues with managing multiple user sessions in express-session

I've been struggling with an issue for a few days now and haven't been able to find a solution. I've scoured forums and documentation, but nothing seems to work. I have a website built in Node.js, using express-session and passport for sessi ...

Utilizing data in mongoose: A beginner's guide

I have two database models: User and Conversations. The User model has the following schema: const userSchema = mongoose.Schema({ username: String, logo: String, ..... }) and the Conversation schema is as follows: const conversationSchema = mongo ...

Leveraging dynamic content in email templates with Mailgun on Node.js server

I've been working on setting up a basic express route to handle my email templates, but I'm having trouble getting the variable names to pass into mailgun. Despite trying multiple ways to input the variables into the data object, the received ema ...

Utilize style as a module in Angular

The issue at hand: Let's take a look at this project structure: /src /public /styles /general /tables.scss /secure /components /someTable1 /someTable.component.ts /someTable.component.css /someTa ...

Utilizing LoopBack Storage Service: Leveraging upload/download functions within JavaScript code

Is there a straightforward way to upload and download files using the storageService.upload and storageService.download functions in my JavaScript/Loopback code? I'm trying to achieve something like this: app.post("/sendFile", (req, res) => client ...