meraj

meraj

After setting up custom nerves hub instance, I am able to create devices and products, add certificates via web. However, whenever I try to create them via command line e.g.:

mix nerves_hub.product create

I am getting this error:
Unhandled error: {:error, {:tls_alert, {:unknown_ca, 'TLS client: In state wait_cert at ssl_handshake.erl:1838 generated CLIENT ALERT: Fatal - Unknown CA\n'}}}

This is a staging setup and the domains are as:

  1. www.staging.mydomain.com - we are able to access this via browser and it shows it has a valid certificate issued by AWS.
  2. api.staging.mydomain.com - it shows the certificate is signed by NervesHub (as I deployed NH custom instance after creating an initial key-chain via nerves_hub repo) and browser also show this error of privacy alert. I had to add an exception to access this web page.
  3. device.staging.mydomain.com - same as above in no 2.

I have tried this both from Mac and Linux after adding these certificates to trusted generated by nerves hub. In code, I am telling it to load all these certificates from:
ca_certs = Path.expand("../ssl/prod", __DIR__)

I don’t know if this error is coming due to self signed certs or anything else. Is there any way I can resolve this error and be able to run these commands from my terminal against custom nerves hub instance and later after creating and installing image on our device, it is also able to communicate with our custom nerves hub instance.

Currently we are trying to achieve this without NervesKey.

Showing Posts 1 to 4

jjcarstens

jjcarstens

Nerves Core Team

The API request still doesn’t have the ca certs it needs. So the real question here is what are you doing with the ca_certs variable you create it? Just assigning the variable doesn’t help us really know where it is.

I’d also check out the doc here Connecting to your environment | NervesHub

Specifically, you need the config :nerves_hub_user_api, ca_certs: ca_certs portion in order for your CLI requests to succeed

meraj

meraj OP

Thank you @jjcarstens I will share the details and code portion from our config.

#config option #1
ca_certs = Path.expand("../ssl/prod", __DIR__)

config :nerves_hub_link,
       device_api_host: "device.staging.customdomain",
       device_api_sni: 'device.staging.customdomain',
       device_api_port: 443,
       ca_certs: ca_certs

config :nerves_hub_user_api,
       host: "api.staging.customdomain",
       port: 443,
      socket: [
        json_library: Jason,
        heartbeat_interval: 45_000
      ],
      ssl: [
        server_name_indication: 'api.staging.customdomain',
        log_level: :debug,
      ],
      fwup_public_keys: [:devkey],
       ca_certs: ca_certs

With this option #1, I am getting the error shared in my original post.

#config option #2
ca_certs = Path.expand("../ssl/prod", __DIR__)

config :nerves_hub_link,
       device_api_host: "device.staging.customdomain",
       device_api_sni: 'device.staging.customdomain',
       device_api_port: 443,
       ca_certs: ca_certs

config :nerves_hub_user_api,
       host: "api.staging.customdomain",
       port: 443,
       server_name_indication: "api.staging.customdomain",
       fwup_public_keys: [:devkey],
       ca_certs: ca_certs

With this option #2, I am getting this error:

Unhandled error: {:error, {:options, {:server_name_indication, “api.staging.customdomain”}}}

This directory ../ssl/prod/ contains all the certs which were generated by the following command and later used in deployment by terraform on AWS:

mix nerves_hub_ca.init --path path/to/nerveshub-terraform/ssl/staging

As I am not sure which certs files to place in ssl/prod, I copied all of them except for keys. Do we need to place only certain cert files there or any other cert I am missing which is causing these errors?

jjcarstens

jjcarstens

Nerves Core Team

Option #2 is what you want. At this point, the error you are getting is probably a mismatch of what is configured in your CA and what you have listed in the server_name_indication option.

For that, you’re going to just need to inspect the cert and server setup to make sure the SNI is what you expect it to be on both ends. This error is showing that the nerves_hub_cli and nerves_hub_user_api are setup correctly and using what they are told - the settings just happen to not match what the server is expecting.

meraj

meraj OP

Thank you @jjcarstens

Yes. It seems so because on server because for staging.customdomain.com the certificate is issued by AWS but for api.staging.customdomain.com, it shows the certificate issued by NervesHub (it seems to be the one which were generated with mix nerves_hub_ca.init --path path/to/nerveshub-terraform/ssl/staging).

— All posts loaded —

Where Next? Top

Trending in Questions Top

Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
Onor.io
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
Trolleger
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
matt-savvy
Anyone here using Honeybadger? My Honeybadger account is being overwhelmed with noise from some bots. Seeing a lot of Bandit.HTTPError...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews