-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
fix: Generate TLS Certificates on startup and only keep in memory #6540
Conversation
8b66666
to
8e585bf
Compare
8e585bf
to
48eb351
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have one comment on this. tls.go
is very large file. I wonder if it is better just to choose a single good set-up, e.g. TLS v1.3 RSA 4096 so that this code does not sit un-used and un-maintained.
That's a fair point, we did consider this but thought first pass to take a copy from argoCD as is. |
Now taken a deeper-dive, I'd like to ask for a more frugal solution. This is 400 new lines of complex code with the attendant risks or many lines of code.
If it is acceptable to have files on disk, e.g. because This was my take on this: https://github.com/argoproj-labs/argo-dataflow/blob/main/runner/sidecar/generate_cert.go Please scrutinise it. It doesn't have the |
8039303
to
b1ca4cb
Compare
} | ||
|
||
var err error | ||
privateKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What ECSDA rather that RSA?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ECSDA is faster, and uses smaller keys to maintain the same/better level of security than that of RSA. Which would require a much larger key and comes with a performance hit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I totally agree with @davidcollom. But please make the particular algorithm configurable and not hard-coded. To test your stuff, I suggest you support both P256 and P521. P256 is OK as the default.
999d58a
to
ff92647
Compare
Head branch was pushed to by a user without write access
ff92647
to
7837bd2
Compare
General question (I know my way around TLS but not Argo): now that the cert is no longer a static file and is stored in memory, should there be an API or command-line option to pull it out of the container? |
Head branch was pushed to by a user without write access
7837bd2
to
ff19ef2
Compare
The certificate is not designed to be taken out of the container in any manor, this is the intention of this change, there are further PR's to address the bring your own certificates. The intention of the Self Signed Certificate is to ensure encryption from an ingress/loadbalancer to the |
} | ||
|
||
var err error | ||
privateKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I totally agree with @davidcollom. But please make the particular algorithm configurable and not hard-coded. To test your stuff, I suggest you support both P256 and P521. P256 is OK as the default.
} | ||
|
||
notBefore := time.Now() | ||
notAfter := notBefore.Add(365 * 24 * time.Hour) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cert duration should be configurable, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is no different to the current master/main duration, of which is NOT configurable.
if you wish to bring your own certificate, then please see other open PR's which look to use kubernetes TLS certificates.
But (as you stated in the mail thread) if the user can fetch the cert, they can put it in their trust store, which is sometimes a good thing - instead of using an unauthenticated connection. Also I am still hoping AWS will see the light and will eventually start verifying TLS connections from the LB. |
Sorry, I don't understand you here? Downloading a key from a public docker image of which EVERYONE on that release is using is by no means secure and as you would also find mentioned is a large security issue. By NOT allowing users to override this, prevents the user from inadvertently and unknowingly open them up to this issue.
Likewise, but this wouldn't be resolved here, I would argue, that this should not be self signed certificates from Argo and should be a bring your own certificate situation from a Corporate or Trusted CA. |
I assume you mean "downloading the cert", not "the key". And I understand your point, but the flip side is that you're educating the user to work with a broken TLS connection ("broken lock"). I don't understand the use case well enough to make a call here. |
template.DNSNames = append(template.DNSNames, h) | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry if I'm repeating myself, I think GH lost one of my comments.
I'm not sure where in the cert these identifiers (IP address, DNS name) are going. Where they should be going is the SubjectAltName
extension, see https://datatracker.ietf.org/doc/html/draft-rsalz-use-san. (The draft is expired but what it says is still relevant).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IPAddresses
and DNSNames
is how one tells Go to fill in the SAN extension, so this bit looks correct as far as filling in the SAN extension
I’d actually want to avoid configurability. It’s extra settings for users to get wrong, and is to have to support. If over time ECC is wrong, then we can release a new version to address that. Users who want to accept certs can use Cert Manager. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ChaosInTheCRD pointed me at this; I took a look and it looks pretty good to me.
Without the ability to export the cert and establish trust out-of-band (i.e. before the first connection is made), it's not possible to use the generated certs safely and it'll always be vulnerable to a man-in-the-middle attack on at least the first connection. I think that's what @yaronf is getting at.
Without the ability to export the cert, there's always that risk. That said, with the cert being regenerated on startup, and a different one being generated for each pod that could be running in a deployment (as far as I can tell?), trying to establish trust ahead-of-time isn't going to work in practice.
Honestly, if I were implementing something like this from scratch, I wouldn't touch this TLS generation stuff and would only do bring-your-own-cert, like in the other PR. If my app was running in k8s, I'd probably have it generate a cert-manger CertificateRequest
and wait for cert-manager to do its thing (but then, as a cert-manager maintainer, of course I would say that 😁)
Obviously this isn't starting from scratch though, and this PR is definitely a big improvement over the current situation - the cert generated by this PR isn't a CA, and crucially isn't the same for every argo-workflows deployment.
Signed-off-by: David Collom <david.collom@jetstack.io>
ff19ef2
to
df03f68
Compare
This is a first pass resolution to issues raised within #6355
the tls util was taken from
argo-cd
's utilities and an additionaltlsConfig
helper added to simplify the initilisation process of the server.