Error: CERT_UNTRUSTED

I try to deploy my project using git push resin master but the following error occurs


I don’t know what is wrong, just following the getting started guide.

Hi. What project are you trying to push?

Thx for prompt feedback. I am trying to push a node js based application. What information can I further provide to get this working ? So far everything went fine. I specified the device, downloaded the resin os, flashed it on the card, put it in the Raspberry PI 3b+ and it connected fine after boot up.
Christian

Are you able to share with us the dockerfile / docker compose file?

Hi again,

Just checking in, are you able to share that Dockerfile or docker-compose with us to take a look?

Thanks!

Does my project need a Dockerfiles ? It is a simple node js project. I saw in the documentation that it generates the Dockerfiles automatically ? I am getting all sorts of weird messages when I push to Balena master. This is all but intuitive.

@gh_smeekmeister
Your project needs to contain a Dockerfile that contains instructions on how to build a container image, which is then downloaded onto your device. For example, in the getting started guide for nodejs ( https://www.balena.io/docs/learn/getting-started/raspberrypi3/nodejs/ ) we use an example project that has a very basic templated Dockerfile that installs your projects dependencies and runs npm start. You can read more about how balena uses Dockerfiles here - https://www.balena.io/docs/learn/develop/dockerfile/ .

Hi,
thx for prompt reply I added the Dockerfile.template used on the simple-server-node project

base-image for node on any machine using a template variable,

see more about dockerfile templates here: https://www.balena.io/docs/learn/develop/dockerfile/#dockerfile-templates

and about balena base images here: https://www.balena.io/docs/reference/base-images/base-images/

FROM balenalib/%%BALENA_MACHINE_NAME%%-node:10-stretch-run

use install_packages if you need to install dependencies,

for instance if you need git, just uncomment the line below.

RUN install_packages git

Defines our working directory in container

WORKDIR /usr/src/app

Copies the package.json first for better cache on later pushes

COPY package.json package.json

This install npm dependencies on the balena build server,

making sure to clean up the artifacts it creates in order to reduce the image size.

RUN JOBS=MAX npm install --production --unsafe-perm && npm cache verify && rm -rf /tmp/*

This will copy all files in our root to the working directory in the container

COPY . ./

Enable udevd so that plugged dynamic hardware devices show up in our container.

ENV UDEV=1

server.js will run when container starts up on the device

CMD [“npm”, “start”]

But it still gives ERR_CERT_UNTRUSTED npm ERR!
Error: CERT_UNTRUSTED

npm
ERR!
at SecurePair. (tls.js:1362:32)
npm ERR!
at SecurePair.EventEmitter.emit (events.js:92:17)
npm
ERR! at SecurePair.maybeInitFinished (tls.js:974:10)
npm

ERR!
at CleartextStream.read [as _read] (tls.js:462:15)

npm

ERR! at CleartextStream.Readable.read (_stream_readable.js:320:10)
npm ERR!
at EncryptedStream.write [as _write] (tls.js:366:25)

npm
ERR! at doWrite (_stream_writable.js:221:10)
npm
ERR!
at writeOrBuffer (_stream_writable.js:211:5)
npm ERR!
at EncryptedStream.Writable.write (_stream_writable.js:180:11)

npm
ERR! at write (_stream_readable.js:583:24)

npm
ERR! If you need help, you may report this log at:

npm

@gh_smeekmeister Would you be able to create a GitHub repo with a minimal reproduction of this issue? I could then run the code on my machine and debug the root cause of this issue

Yes I can. It is also already a GitHub repository. How can I give you access to it ?

Hi @gh_smeekmeister If the repo is private, you can add my github account (lucianbuzzo) as a collaborator and send me a link on the forums via private message.

@gh_smeekmeister Your node project has a dependency on the serialport library, which has a dependency on Python and also requires that compiler tools are available on your system, see https://serialport.io/docs/en/guide-installation#compilation-problems . If you add this line before the npm install step in your project’s Dockerfile.template than the necessary compiler tools and Python will be installed and the install should complete correctly.

RUN apt-get update && apt-get install python make g++ -y

You will also need to make sure that the CMD command at the bottom of the Dockerfile.template starts your node application, otherwise the built docker image will not start correctly.

Hi Lucian,
Thanks a lot!!. I managed to get it to work now.
When the image was building, I couldn’t help to see in the log rp1
Am I using the right image ? The devices are Raspberry PI3b+

Hi Lucian,

I stumbled into a new build problem. I want to use device service variables in my node program so that each device can listen to its appropriate location on the server platform.
To that purpose I have done npm install of the balena-sdk and added some sample code in the program just to log if it finds the variables (before I start using them in the program)

const balena = require('balena-sdk)
balena.models.application.envVar.get( etc etc. console.log(value)

I pushed the updates to the git repository and pushed it to balena master and I am running again into a build error I don’t understand.

Underneath the log in the console.

Starting build for pod_controller, user gh_smeekmeister
[Info] Dashboard link: https://dashboard.balena-cloud.com/apps/1287951/devices
[Info] Building on arm03
[Info] Pulling previous images for caching purposes…
[Success] Successfully pulled cache images
[main] Step 1/8 : FROM balenalib/raspberrypi3-node:10-stretch-run
[main] —> bb69c3052f0a
[main] Step 2/8 : WORKDIR /usr/src/app
[main] Using cache
[main] —> 07c512ad5530
[main] Step 3/8 : COPY package.json package.json
[main] Using cache
[main] —> 94eafa66f59b
[main] Step 4/8 : RUN apt-get update && apt-get install python make g++ -y
[main] Using cache
[main] —> 8eacfe929d90
[main] Step 5/8 : RUN JOBS=MAX npm install --production --unsafe-perm && npm cache verify && rm -rf /tmp/*
[main] —> Running in 8e789711d6f9
[main] npm ERR! code ENOGIT
[main]
[main] npm ERR! Error while executing:
[main]
[main] npm
[main]
[main] ERR!
[main] undefined ls-remote -h -t ssh://git@github.com/resin-io-modules/node-web-streams.git
[main] npm ERR!
[main]
[main] npm
[main] ERR!
[main] undefined
[main]
[main] npm
[main]
[main] ERR!
[main] No git binary found in $PATH
[main]
[main] npm ERR!
[main]
[main] npm
[main]
[main] ERR!
[main] Failed using git.
[main] npm ERR!
[main] Please check if you have git installed and in your PATH.
[main]
[main]
[main] npm
[main] ERR!
[main] A complete log of this run can be found in:
[main]
[main] npm
[main]
[main] ERR!
[main] /root/.npm/_logs/2019-02-28T13_18_00_732Z-debug.log
[main]
[main] Removing intermediate container 8e789711d6f9
[main] The command ‘/bin/sh -c JOBS=MAX npm install --production --unsafe-perm && npm cache verify && rm -rf /tmp/’ returned a non-zero code: 1
[Info] Uploading images
[Success] Successfully uploaded images
[Error] Some services failed to build:
[Error] Service: main
[Error] Error: The command '/bin/sh -c JOBS=MAX npm install --production --unsafe-perm && npm cache verify && rm -rf /tmp/
’ returned a non-zero code: 1
[Error] Not deploying release.

remote: error: hook declined to update refs/heads/master
To git.balena-cloud.com:gh_smeekmeister/pod_controller.git
! [remote rejected] master -> master (hook declined)
error: failed to push some refs to ‘gh_smeekmeister@git.balena-cloud.com:gh_smeekmeister/pod_controller.git’
Christians-MacBook-Pro:itl-iot smekens$

I guess I need to install git so I unmarked the “RUN install_packages” git command in the Dockerfile template but now I get another error [Error] An error occurred: ESOCKETTIMEDOUT
[Error] Not deploying release.

Hi Lucian,
It’s solved. The RUN command did it. the Error socket things was apparently a general issue with build servers affecting the whole of balena. Apparently that’s solved now.