Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple JITP CA per product #871

Closed
jeanparpaillon opened this issue Dec 8, 2022 · 4 comments
Closed

Multiple JITP CA per product #871

jeanparpaillon opened this issue Dec 8, 2022 · 4 comments

Comments

@jeanparpaillon
Copy link

Hi all,
If I understand correctly (https://github.com/nerves-hub/nerves_hub_web/blob/main/apps/nerves_hub_web_core/priv/repo/migrations/20210511162245_add_jitp_to_ca_certificates.exs#L12 ), only one CA per product can be JITP-enabled.

I would like to be able to have multiple CA per product, with JITP enabled.

@fhunleth
Copy link
Contributor

fhunleth commented Dec 8, 2022

The relation is the other way. @jjcarstens can comment on that line. However, it should be many CAs to one product.

A CA can only JITP for one product, though. You can't have one CA JITP'ing for multiple products since NH wouldn't know which product to assign to the device when it first authenticates.

@jeanparpaillon
Copy link
Author

I understand a CA can only JITP for one product.
I may be wrong, but on line 12, create unique_index(:jitp, [:product_id]) enforces a single JITP enabled CA per product.
From https://github.com/nerves-hub/nerves_hub_web/blob/main/apps/nerves_hub_web_core/lib/nerves_hub_web_core/products/product.ex#L22 , we have in Product : has_one :jitp

@jjcarstens can you explain this limitation ?

@jjcarstens
Copy link
Collaborator

Right now there is a hard limitation of one JITP CA per product because of that unique index (as @jeanparpaillon said). But we should probably remove that so unique index so that many CAs can JITP one product (as @fhunleth said). The way CAs are structured already enforces that a CA can only JITP for one product

FWIW, we had discussed this need for our internal instance, but then moved away from using JITP entirely and hadn't circled back to it. I believe we can simply just remove the linked index for :product_id on JITP records

@fhunleth
Copy link
Contributor

fhunleth commented Dec 8, 2022

Got it. I forgot the discussion and just assumed that it was working for us internally at one time. The restriction doesn't make sense, and if it's as simple as removing the linked index for :product_id, then I'm definitely for it.

jeanparpaillon pushed a commit to OffgridElectric/nerves_hub_web that referenced this issue Dec 20, 2022
Actual relation between jitp and product is has_one. There is no valid
reason for limiting JITP enabled certificate to one per product.

This commit:
* updates Ecto schema
* adds migration to remove unique_index on jitp.product_id

Fixes nerves-hub#871
jeanparpaillon pushed a commit to OffgridElectric/nerves_hub_web that referenced this issue Dec 21, 2022
Actual relation between jitp and product is has_one. There is no valid
reason for limiting JITP enabled certificate to one per product.

This commit:
* updates Ecto schema
* adds migration to remove unique_index on jitp.product_id

Fixes nerves-hub#871
oestrich pushed a commit that referenced this issue Mar 22, 2023
Actual relation between jitp and product is has_one. There is no valid
reason for limiting JITP enabled certificate to one per product.

This commit:
* updates Ecto schema
* adds migration to remove unique_index on jitp.product_id

Fixes #871
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants