-
Notifications
You must be signed in to change notification settings - Fork 2k
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
fix mTLS certificate check on agent to agent RPCs #11998
Conversation
PR #11956 implemented a new mTLS RPC check to validate the role of the certificate used in the request, but further testing revealed two flaws: 1. client-only endpoints did not accept server certificates so the request would fail when forwarded from one server to another. 2. the certificate was being checked after the request was forwarded, so the check would happen over the server certificate, not the actual source. This commit checks for the desired mTLS level, where the client level accepts both, a server or a client certificate. It also validates the cercertificate before the request is forwarded.
@@ -1186,7 +1186,7 @@ func TestRPC_TLS_Enforcement_RPC(t *testing.T) { | |||
name: "local server/clients only rpc", | |||
cn: "server.global.nomad", | |||
rpcs: localClientsOnlyRPCs, | |||
canRPC: false, | |||
canRPC: true, |
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 caused problem 1
to go unnoticed. Server certificates should be able to call client RPCs
if tc.canRPC { | ||
if err != nil { | ||
require.NotContains(t, err, "certificate") | ||
for _, srv := range []*Server{tlsHelper.mtlsServer1, tlsHelper.mtlsServer2} { |
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 tests problem 2
by using a two server cluster and making requests to both. One of the requests will need to be forwarded.
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.
Great catch!
@schmichael @lgfa29 With a recent upgrade we've lost our tls verification between servers and clients. Normally we're using vault's mtls certificate endpoint with the This is from consul-template, it's obvious that
And this is what I got from nomad log:
There's certainly a problem with the recent changes, I'm just trying to figure out what caused this :) |
Hi @samed This PR hasn't been released yet so it can't be causing that error (the error message is also slightly different in Did anything change in your mTLS setup? From the error message it seems like you may be using a wildcard certificate in your servers? |
Thanks for the reply. We haven't changed anything in mtls setup but the upgrade was from 1.1.2 to 1.2.5, so I'll be checking for diffs between those :) Note on slightly different log, I tried to merge/combine several lines from my clipboard, but the exact error was that. |
Ah OK, so this check was introduced in 1.1.4, that's why you weren't seeing it before. |
I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions. |
PR #11956 implemented a new mTLS RPC check to validate the role of the
certificate used in the request, but further testing revealed two flaws:
request would fail when forwarded from one server to another.
so the check would happen over the server certificate, not the
actual source.
This PR checks for the desired mTLS level, where the client level
accepts both, a server or a client certificate. It also validates the
cercertificate before the request is forwarded.
#11956 was never released, so no CHANGELOG needed.