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

clientv3: Set authority used in cert checks to host of endpoint #11184

Merged
merged 1 commit into from
Oct 3, 2019

Conversation

jpbetz
Copy link
Contributor

@jpbetz jpbetz commented Sep 25, 2019

Fixes #11180

This is a workaround for the gPRC load balancer, which currently uses the "service name" (which the etcd client was setting to the 1st endpoint's hostname or IP) as authority for all credential checks for all the endpoints it load balances against, which does not work well for configurations where etcd servers use a Subject Alternative Names in their certs set to their hostname or IP. We previously added a workaround to fix this problem for IPs (db61ee1) but not hostnames.

The workaround keeps track of the endpoints the load balancer dials and overwrites the authority in ClientHandshake before the cert checks are performed so that the authority is always the host of the endpoint that the client was originally configured with. For example, if a client is configured with:

--endpoints=member1.etcd.xyz:2379,member2.etcd.xyz:2379,member3.etcd.xyz:2379"

The authorities of the endpoints will now be member1.etcd.xyz, member2.etcd.xyz and member3.etcd.xyz respectively. Previously, the authority of member1.etcd.xyz was used for all endpoints.

I've manually verified with etcdctl that this does result in the correct authority being used in DNS name SAN cert checks.

@gyuho @jingyih @wenjiaswe

@gyuho gyuho self-assigned this Sep 25, 2019
@jpbetz jpbetz force-pushed the correct-authority-checks branch 2 times, most recently from a35b10a to 507f680 Compare September 25, 2019 21:40
@jpbetz jpbetz changed the title WIP - clientv3: Set authority used in cert checks to host of endpoint clientv3: Set authority used in cert checks to host of endpoint Sep 25, 2019
}
}

func (tc *transportCredential) OverrideServerName(serverNameOverride string) error {
return tc.gtc.OverrideServerName(serverNameOverride)
}

func (tc *transportCredential) Dialer(ctx context.Context, dialEp string) (net.Conn, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

So, gRPC first calls Dialer and by the time it calls, ClientHandshake, the remote address will always have been populated in addrToEndpoint, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And here's where the authority gets set: https://github.com/grpc/grpc-go/blob/230def769105c46b2e597578b23002a6ac159dde/clientconn.go#L1142.

We're basically just trying to get the authority set to an appropriate value for each endpoint instead of having a single value for the entire set of endpoints.


// Dialer dials a endpoint using net.Dialer.
// Context cancelation and timeout are supported.
func Dialer(ctx context.Context, dialEp string) (net.Conn, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice clean-up by moving code here!

Copy link
Contributor

@gyuho gyuho left a comment

Choose a reason for hiding this comment

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

lgtm, thanks for the quick fix!

@jpbetz
Copy link
Contributor Author

jpbetz commented Sep 25, 2019

Great, let's hold off for just a bit before we merge to get feedback from the grpc team.

@jingyih
Copy link
Contributor

jingyih commented Sep 25, 2019

Thanks for the quick fix! Implementation looks very clean.

@jpbetz jpbetz merged commit 6e74099 into etcd-io:master Oct 3, 2019
@jpbetz
Copy link
Contributor Author

jpbetz commented Oct 3, 2019

Merging this to master. I'd like to improve test coverage before we backport to 3.4.

spzala added a commit to spzala/etcd that referenced this pull request Dec 2, 2019
spzala added a commit to spzala/etcd that referenced this pull request Dec 2, 2019
YoyinZyc added a commit to YoyinZyc/etcd that referenced this pull request Jan 30, 2020
tgraf added a commit to cilium/cilium that referenced this pull request Feb 28, 2020
This bumps the etcd dependency in order to pull in
github.com/etcd-io/etcd/pull/11184 which is required to fix a gRPC load
balancer issue when using a k8s service name to connect to etcd.

Fixes: #9791

Signed-off-by: Thomas Graf <thomas@cilium.io>
tgraf added a commit to cilium/cilium that referenced this pull request Feb 28, 2020
This bumps the etcd dependency in order to pull in
github.com/etcd-io/etcd/pull/11184 which is required to fix a gRPC load
balancer issue when using a k8s service name to connect to etcd.

Fixes: #9791

Signed-off-by: Thomas Graf <thomas@cilium.io>
brb pushed a commit to cilium/cilium that referenced this pull request Mar 2, 2020
[ upstream commit 26e3ca0 ]

This bumps the etcd dependency in order to pull in
github.com/etcd-io/etcd/pull/11184 which is required to fix a gRPC load
balancer issue when using a k8s service name to connect to etcd.

Fixes: #9791

Signed-off-by: Thomas Graf <thomas@cilium.io>
Signed-off-by: Martynas Pumputis <m@lambda.lt>
joestringer pushed a commit to cilium/cilium that referenced this pull request Mar 4, 2020
[ upstream commit 26e3ca0 ]

This bumps the etcd dependency in order to pull in
github.com/etcd-io/etcd/pull/11184 which is required to fix a gRPC load
balancer issue when using a k8s service name to connect to etcd.

Fixes: #9791

Signed-off-by: Thomas Graf <thomas@cilium.io>
Signed-off-by: Martynas Pumputis <m@lambda.lt>
chaochn47 pushed a commit to chaochn47/etcd that referenced this pull request Oct 25, 2023
…after bumping grpc to 1.26.0.

Signed-off-by: Chao Chen <chaochn@amazon.com>
chaochn47 pushed a commit to chaochn47/etcd that referenced this pull request Oct 27, 2023
…after bumping grpc to 1.26.0.

Signed-off-by: Chao Chen <chaochn@amazon.com>
chaochn47 pushed a commit to chaochn47/etcd that referenced this pull request Oct 27, 2023
…after bumping grpc to 1.26.0.

Signed-off-by: Chao Chen <chaochn@amazon.com>
ahrtr added a commit that referenced this pull request Oct 27, 2023
Backport [3.4] clientV3: simplify grpc dialer usage. Remove workaround #11184 after bumping grpc to 1.26.0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

etcd client with multiple endpoints fails certificate checks due to hostname mismatch
3 participants