43 Commits

Author SHA1 Message Date
Volodymyr Khoroz
1cf5a72794 Feature: support multiple root CA certificates
This is needed to support the root CA renewal feature.
During the initial phase of that renewal, a server needs to send clients:
- A new root CA,
- A cross-signed copy of that new CA, so that clients can validate the chain of trust using a previous root CA,
- And a previous root CA, so that clients can still trust the existing server TLS certificates during interregnum.

Signed-off-by: Volodymyr Khoroz <volodymyr.khoroz@foundries.io>
2024-06-17 19:26:56 +03:00
Volodymyr Khoroz
f8ac1e1308 Fixup: do not allow client certs signed by root CA
We should only allow client certs signed by client CAs, not the root CA.

Signed-off-by: Volodymyr Khoroz <volodymyr.khoroz@foundries.io>
2024-06-17 19:10:51 +03:00
Volodymyr Khoroz
a1f536d568 Fixup: fix a panic on empty or invalid certificate files
Signed-off-by: Volodymyr Khoroz <volodymyr.khoroz@foundries.io>
2024-06-17 19:02:49 +03:00
Volodymyr Khoroz
eb91d754a5 Cleanup: add Vim cache files to .gitignore
Signed-off-by: Volodymyr Khoroz <volodymyr.khoroz@foundries.io>
2024-06-17 19:02:22 +03:00
Volodymyr Khoroz
046d46ce26 Fixup: fix make check to work and add make lint
The linter local variable was not initialized.
Also, put the linter version into sync with what the GitHub action uses.

Signed-off-by: Volodymyr Khoroz <volodymyr.khoroz@foundries.io>
2024-06-17 19:00:58 +03:00
Ricardo Salveti
cbd64f4428 Relicense from Apache-v2 to BSD-3 Clause
Signed-off-by: Ricardo Salveti <ricardo@foundries.io>
2024-03-01 21:54:59 -03:00
Andy Doan
69a5252074 go.mod: Bump x/crypto for CVE
https://github.com/advisories/GHSA-45x7-px36-x8w8

Signed-off-by: Andy Doan <andy@foundries.io>
2024-01-09 16:22:35 -06:00
Andy Doan
70a7ccee37 README: Add details for devices registered before PKI
We have users that go to production before they've taken ownership of
their PKI. This means the "issuer" of their devices is the Foundries
default online CA. We've added a new API to retrieve this so that users
can add this value to their allowed CAs list for their EST server.

Signed-off-by: Andy Doan <andy@foundries.io>
2024-01-02 09:33:22 -06:00
Andy Doan
a161c54474 Make validateRequest handling more foolproof
Signed-off-by: Andy Doan <andy@foundries.io>
2023-12-14 11:51:57 -06:00
Andy Doan
583ad2b807 Merge pull request #13 from foundriesio/fixes
Fix issues found from more complex usage
2023-12-14 11:47:01 -06:00
Andy Doan
8c19c0a3b5 main: Fix loading of client CAs
This happened to work because I usually test it with the "local-ca"
used by the est server *and* my factory registration reference server.
However, when you need to trust many client ca's, this was totally
broken.

Signed-off-by: Andy Doan <andy@foundries.io>
2023-12-13 16:34:01 -06:00
Andy Doan
751724a936 handlers: Fix bad error handling
We had the right intentions with `validateRequest`. However, we weren't
handling its return value correctly when it actually failed.

Signed-off-by: Andy Doan <andy@foundries.io>
2023-12-13 15:53:51 -06:00
Andy Doan
8ed8ec3305 README: Update with steps for latest fioctl
The latest fioctl makes this a little cleaner.

Signed-off-by: Andy Doan <andy@foundries.io>
2023-12-13 15:38:17 -06:00
Andy Doan
cd5cd710d5 Merge pull request #9 from foundriesio/cert-expiry
Allow cert duration to be configurable
2023-12-07 13:25:58 -06:00
Andy Doan
b176faa28e Make cert duration configurable with 3 year default
1 year was too short for what most people want in large fleets

Signed-off-by: Andy Doan <andy@foundries.io>
2023-12-07 13:24:21 -06:00
Andy Doan
3c980ab15c Fix linter warning about errors starting with capital letter
Signed-off-by: Andy Doan <andy@foundries.io>
2023-12-06 15:53:51 -06:00
Andy Doan
a7f1d3c9c6 Clean up linter warning about error naming
Signed-off-by: Andy Doan <andy@foundries.io>
2023-12-06 15:53:51 -06:00
Andy Doan
1b32b40729 readme: Update with fioconfig information
Signed-off-by: Andy Doan <andy@foundries.io>
2023-01-17 21:21:09 -06:00
Andy Doan
bfbf52d8b2 main: Allow devices signed by all factory CAs to authenticate
Before this change you could only rotate certs for devices that were
signed by the local-ca configured for this server. This allows you to
use a list of CAs (like we do for our managed instance)

Signed-off-by: Andy Doan <andy@foundries.io>
2023-01-17 21:19:29 -06:00
Andy Doan
022f3b0509 main: Ignore extra whitespace in PEM files
Signed-off-by: Andy Doan <andy@foundries.io>
2023-01-17 21:02:05 -06:00
Andy Doan
40d2c1052a main: Use common PEM parsing
* Make better use of context logger
* Fixes a compiler warning about len(bytes) and comparing to nil

Signed-off-by: Andy Doan <andy@foundries.io>
2023-01-17 20:58:27 -06:00
Andy Doan
2b58d6f2e7 Log the public key when creating a new cert
Could be helpful for auditing and debugging

Signed-off-by: Andy Doan <andy@foundries.io>
2022-10-20 20:43:04 -05:00
Andy Doan
ad98f72bf9 Abstract logic for looking up Service instance
When we run in a multi-tenant mode, the http handlers must be able to
dynamically look up which est service instance to use based on the
server name.

Signed-off-by: Andy Doan <andy@foundries.io>
2022-10-19 09:30:21 -05:00
Andy Doan
415b2c73d4 Small fixes for working with private est server
Signed-off-by: Andy Doan <andy@foundries.io>
2022-10-18 11:46:24 -05:00
Andy Doan
43d885f505 Merge pull request #4 from foundriesio/graceful-shutdown
main: Perform a graceful shutdown
2022-10-18 11:42:16 -05:00
StealthyCoder
6418d604c5 Merge pull request #5 from StealthyCoder/docs/update
docs(README): Updated readme
2022-10-15 01:43:23 +02:00
Eric Bode
412d1ed08a docs(README): Updated readme
Mostly just added the fact we implement the update RFC8951.
2022-10-13 21:32:18 +02:00
Andy Doan
c4eb98eee5 main: Perform a graceful shutdown
Copied logic from:

 78b9c98c5c/registry/registry.go (L299)

Signed-off-by: Andy Doan <andy@foundries.io>
2022-10-12 21:24:05 -05:00
Andy Doan
17bd45c527 middleware: Log device and factory when present
Signed-off-by: Andy Doan <andy@foundries.io>
2022-10-12 08:55:53 -05:00
Andy Doan
3bafd6e486 README: update usage instructions
Signed-off-by: Andy Doan <andy@foundries.io>
2022-10-11 21:37:00 -05:00
Andy Doan
48f12fd1fb Add GitHub PR support 2022-10-10 21:26:09 -05:00
Andy Doan
bfb8ccfa7c Add some stuff to help make project usable
Signed-off-by: Andy Doan <andy@foundries.io>
2022-10-10 16:45:04 -05:00
Andy Doan
38004167cb Create a main method for standalone server
Signed-off-by: Andy Doan <andy@foundries.io>
2022-10-10 16:37:38 -05:00
Andy Doan
10e4577582 Introduce http handler for "simplereenroll"
Signed-off-by: Andy Doan <andy@foundries.io>
2022-10-10 16:37:31 -05:00
Andy Doan
cadc9b54c4 Introduce http handler for "simpleenroll"
Signed-off-by: Andy Doan <andy@foundries.io>
2022-10-10 16:36:57 -05:00
Andy Doan
c05be17eb7 Introduce HTTP skeleton
Signed-off-by: Andy Doan <andy@foundries.io>
2022-10-10 16:36:57 -05:00
Andy Doan
daeb60a63a Create a flexible TLS server abstraction
This project needs to be run in 2 different ways:

 * Directly in a customer environment (typical TLS requirements)
 * multi-tenant K8s in foundries backend (like our device-gateway and
   ostree-hub).

In the multi-tenant case, we have special logic to look at the incoming
SNI information in the request and use the correct certs for a factory.

This commit introduces the abstraction and simple single-tenant
implementation. Foundries can then extend this project with their own
handler to satisfy their requirements.

Signed-off-by: Andy Doan <andy@foundries.io>
2022-10-10 16:36:56 -05:00
Andy Doan
4482b0f127 EST: Document what's implemented and not implemented
Signed-off-by: Andy Doan <andy@foundries.io>
2022-10-10 16:36:55 -05:00
Andy Doan
0cb50fabfe EST 4.2.2: Simple Re-enrollment of Clients
Signed-off-by: Andy Doan <andy@foundries.io>
2022-10-10 14:25:18 -05:00
Andy Doan
19f8bf713e EST 4.2.1: Simple Enrollment of Clients
Signed-off-by: Andy Doan <andy@foundries.io>
2022-10-10 14:20:46 -05:00
Andy Doan
53814b5600 EST 4.1.2: CA Certificate Request
This resource returns the factory's root CA

Signed-off-by: Andy Doan <andy@foundries.io>
2022-10-10 14:11:59 -05:00
Andy Doan
968775e9a7 Introduce the EST Service interface
This interface will be used by our HTTP handlers to fulfill incoming
EST requests.

Signed-off-by: Andy Doan <andy@foundries.io>
2022-10-10 13:25:46 -05:00
Andy Doan
7db7de5173 Initial commit
Copy some of our internal logging logic into the project to be used
throughout.

Signed-off-by: Andy Doan <andy@foundries.io>
2022-10-10 13:13:57 -05:00