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

Stop serving and fetching the tls cert used for gRPC #584

Merged
merged 21 commits into from
Apr 18, 2022

Conversation

mmlb
Copy link
Contributor

@mmlb mmlb commented Jan 27, 2022

Description

  • Stops serving the gRPC cert via http and stops fetching it.
  • Cleans up a ton of code that was confusing to read in the clients due to dealing with the gRPC certificate.
  • Removes a few Config structs that are passed into funcs
    These were used to get around having lots of parameters and the long lines that caused, but now are just one or two values.

Why is this needed

The whole serving of the gRPC certificate via http as /cert should never have made it to tinkerbell.
It's too easy to use incorrectly and fall into a sense of security that may not be there.
Its also a pain to actually use in production when following modern best practices of short lived TLS certificates.
Clients can't use gRPC's/Go's builtin certificate handling of when certs are rotated.

This is not a lot of good, yet a bunch of bad only to make a corner case easier at the expense of normal route.
/cert makes self-sigend certs "easy"ish (see cert rotation issue still) but it's just not worth it.
If someone can handle the implications of self-signed certs in production (#567 can be used for dev envs) then they can figure out how to embed their CA into hook or roll their own tink-worker environment.

How Has This Been Tested?

Compiles and tests pass.

How are existing users impacted? What migration steps/scripts do we need?

This is a breaking change for out-of-tree clients, I think its worth it compared to the ops / security benefits.

Fixes #324

@codecov
Copy link

codecov bot commented Jan 27, 2022

Codecov Report

Merging #584 (f52167c) into main (453f0fd) will decrease coverage by 0.35%.
The diff coverage is 31.11%.

❗ Current head f52167c differs from pull request most recent head dc46a51. Consider uploading reports for the commit dc46a51 to get more accurate results

@@            Coverage Diff             @@
##             main     #584      +/-   ##
==========================================
- Coverage   46.22%   45.86%   -0.36%     
==========================================
  Files          56       56              
  Lines        3310     3268      -42     
==========================================
- Hits         1530     1499      -31     
+ Misses       1690     1686       -4     
+ Partials       90       83       -7     
Impacted Files Coverage Δ
cmd/tink-cli/cmd/root.go 0.00% <0.00%> (-33.34%) ⬇️
server/dbserver.go 0.00% <ø> (ø)
server/dbserver_hardware.go 2.45% <ø> (+0.04%) ⬆️
cmd/tink-cli/cmd/delete/delete.go 85.71% <100.00%> (+18.27%) ⬆️
cmd/tink-cli/cmd/get/get.go 79.16% <100.00%> (+9.16%) ⬆️
grpc-server/grpc_server.go 93.10% <100.00%> (+17.49%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 453f0fd...dc46a51. Read the comment docs.

cmd/tink-cli/cmd/root.go Outdated Show resolved Hide resolved
grpc-server/grpc_server.go Outdated Show resolved Hide resolved
cmd/tink-cli/cmd/root.go Outdated Show resolved Hide resolved
@mmlb mmlb force-pushed the drop-cert branch 2 times, most recently from fa05ac2 to b1e4f5b Compare February 10, 2022 20:57
@mmlb mmlb force-pushed the drop-cert branch 5 times, most recently from 4af365c to b885e17 Compare February 11, 2022 15:49
@mmlb mmlb marked this pull request as ready for review February 11, 2022 15:50
mmlb added a commit to mmlb/tinkerbell-hook that referenced this pull request Feb 14, 2022
@displague
Copy link
Member

@mmlb looks like this will need a rebase and to follow along with @micahhausler's refactoring done in #598

Copy link
Contributor

@micahhausler micahhausler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really good! Just a few minor comments

client/main.go Show resolved Hide resolved
client/main.go Show resolved Hide resolved
client/main.go Show resolved Hide resolved
client/main.go Outdated Show resolved Hide resolved
cmd/tink-cli/cmd/internal/clientctx/main.go Outdated Show resolved Hide resolved
cmd/tink-worker/cmd/root.go Outdated Show resolved Hide resolved
docs/ENVVARS.md Show resolved Hide resolved
grpc-server/grpc_server.go Show resolved Hide resolved
grpc-server/grpc_server_test.go Show resolved Hide resolved
cmd/tink-worker/cmd/root.go Show resolved Hide resolved
@micahhausler micahhausler mentioned this pull request Apr 8, 2022
3 tasks
mmlb added 9 commits April 15, 2022 11:44
This was only ever a hack that was moderately ok when it was done in Cacher
when running in an old EM orchestration stack. IT was ok because we *always*
fetched the cert via a "normal" tls connection via a tls terminating proxy.
This was not guaranteed in tinkerbell land and actually exists insecurely in
the sandbox at the moment (see sandbox fetching the cert via http).

Having this here made self-signed certs "easier" but also less safe while making
the normal and desired behavior more difficult. The normal being tinkerbell
using cert generated by a trusted CA. This way certificate revokation can
actually happen, where as with the /cert method all clients would have to
redownload the /cert after figuring out the cert is no longer valid (somehow).

This should never have made it into tinkerbell from cacher.

Signed-off-by: Manuel Mendez <[email protected]>
Now that we don't need the certificate in pem format nor the cert's
modification time we can drop a whole lot of complexity and use more
functionality from the imported libs.

Signed-off-by: Manuel Mendez <[email protected]>
They no longer matter.

Signed-off-by: Manuel Mendez <[email protected]>
It's just one member so might as well drop it in favor of just passing value as an arg.

Signed-off-by: Manuel Mendez <[email protected]>
It's just two members so might as well drop it in favor of just passing values
as a args.

Signed-off-by: Manuel Mendez <[email protected]>
Get rid of init() func and the function it calls too. I find it much easier to
understand the code flow and how viper/cobra interact by setting evertying up
in Execute.

Signed-off-by: Manuel Mendez <[email protected]>
Previously rootCmd's cobra.Command had not been able to run and thus the
command line arguments weren't yet parsed by the time we were connecting
to tinkerbell. Environment vars would work which is how we usually set
everything up so went undetected. By waiting until PreRun we give cobra a
chance to parse the command line and thus we do the right thing.

Signed-off-by: Manuel Mendez <[email protected]>
It really is.

Signed-off-by: Manuel Mendez <[email protected]>
We don't generate certificates in tink-server any more.

Signed-off-by: Manuel Mendez <[email protected]>
micahhausler
micahhausler previously approved these changes Apr 15, 2022
Copy link
Contributor

@micahhausler micahhausler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mmlb mmlb added the ready-to-merge Signal to Mergify to merge the PR. label Apr 15, 2022
cmd/tink-server/Dockerfile Outdated Show resolved Hide resolved
mmlb and others added 3 commits April 18, 2022 16:51
For easier back-and-forth mental-modelling.

Signed-off-by: Manuel Mendez <[email protected]>
Aborting from withing a library package...., should never have been committed!

Signed-off-by: Manuel Mendez <[email protected]>
Copy link
Contributor

@markjacksonfishing markjacksonfishing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@mmlb mmlb removed the request for review from displague April 18, 2022 21:27
@mergify mergify bot merged commit 4769080 into tinkerbell:main Apr 18, 2022
@mmlb mmlb deleted the drop-cert branch April 18, 2022 21:34
mergify bot added a commit to tinkerbell/smee that referenced this pull request May 4, 2022
## Description

I was getting ready to PR my branch that is updated to work in /cert-less tink (now that tinkerbell/tink#584 is merged) and it was basically a situation where pulling one thread unraveled a bunch of other things. Dropping /cert begot some refactors (started by dropping the `buildWorkerParams` silliness) which begot some test fixes which begot some other refactors which was also dumb to do for rancher, nixos, and centos. So here we are.

## Why is this needed

Makes updating to post tinkerbell/tink#584 easier/nicer.

## How Has This Been Tested?

Ran unit tests.

## How are existing users impacted? What migration steps/scripts do we need?

Less EM specific junk is always good. Less duplicate/unclear tests too. This PR does introduce a change wrt sandbox, where MIRROR_HOST is dropped in favor of MIRROR_BASE_URL, I'll follow up with a PR there once this merges.

## Checklist:

I have:

- [ ] updated the documentation and/or roadmap (if required)
- [ ] added unit or e2e tests
- [ ] provided instructions on how to upgrade
@displague displague added this to the 0.7.0 milestone Aug 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge Signal to Mergify to merge the PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tink GRPC client panics on bad TINKERBELL_CERT_URL
4 participants