-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
HTTP2 authority header is not set to resolver.Address.ServerName (?) #4516
Comments
What that godoc says is, the ServerName is used as the authority in the TLS handshake, not set as the It seems the server is complaining because We have several options:
@dfawley what do you think? @markdroth @ejona86 |
Another potential option:
|
Thanks a lot for the fast response. If I use a dial URL like In my example the resolver ( |
Java and C both let the name resolver convert from the target string to the authority. Does Go not allow the same? Note that it must be a local computation based on the target string; no looking up in a foreign DB. With that approach the Consul name resolver would determine what the authority should be, which appears to be "strip off the query params" in this case. While I think it'd be an abuse of Address.ServerName to use it in this case (it is a dangerous tool and we should avoid it when possible), I'm surprised to hear the setting doesn't change the I am aware of cases where we expect to have "invalid" characters in authority, namely It looks like the current behavior of grpc-java disallows percent-encoding when calling Aside: percent-encoding can "naturally" come up with IPv6 scopes, but we ignore the case. https://datatracker.ietf.org/doc/html/rfc6874#section-2 . Note that Windows interface names have spaces by default, so those also have to be percent encoded. But that's a different discussion because they are supposed to be removed from the host header (although then it seems the server cannot create absolute URLs in the response). https://datatracker.ietf.org/doc/html/rfc6874#section-4 |
Yeah, as Eric said, in C-core, the resolver determines what authority to use for a given URI, so it should be totally up to the consul resolver implementation what to do here. However, note that the default behavior in the base class (used if not overridden by an individual resolver implementation) is to use to path part of the URI, stripping off the leading |
In Java the customary behavior is essentially |
Thanks for the replies. It seems a main difference is the resolver interface
No, this isn't available in Go. But it isn't too hard to add one.
@ejona86 Are you suggesting we should also set |
Yes, that is what I was suggesting. Generally speaking we shouldn't use an I'm not aware of any case where we need to use an :authority for a host that does not have a certificate for that authority. |
With #4817, we changed the way grpc-go parses the target URI and made it more compliant with RFC 3986. We still haven't added the ability for name resolvers to return @fho : Could you please let us know if you are still facing the same issue with the latest version of grpc-go. Thank you. |
This issue is labeled as requiring an update from the reporter, and no update has been received after 6 days. If no update is provided in the next 7 days, this issue will be automatically closed. |
Thanks for checking @fho. |
Hello,
according to the godoc and this comment,
the HTTP2 authority header field is set to the
resolver.Address.ServerName
value that is returned by a resolver.I can not reproduce this with grpc-go 1.38.0 nor with v1.39.0-dev.0.20210603231021-5c164e2b8f22.
If I understand the code correctly, the http2 authority header is set here to
cc.authority
andcc.authority
is set depending on the parameters ofDialContext
.Therefore HTTP2 authority field is never set to
resolver.Address.ServerName
.Do I understand something wrong or is this a bug?
(When I set a custom authority via the
grpc.WithAuthority()
dial option, the authority is set accordingly.)Some more context, why this became an issue for me:
I'm maintaining a consul grpc-go resolver.
The resolver accepts a custom URL via
grpc.Dial()
in the format:consul://[<consul-server>]/<serviceName>[?<OPT>[&<OPT>]...]
.It queries a
consul-server
for the addresses ofserviceName
and returns it addresses.The resolver was only setting the
resolver.Address.Addr
, notresolver.Address.ServerName
.When the GRPC-Requests are send out the HTTP2 authority header field is set to a bogus value, to the
<serviceName>[?<OPT>[&<OPT>]...]
part of the URL. This part is parsed here as authority.This was not a problem when communicating with grpc-go servers, they seem to ignore the bogus authority value.
When communicating with grpc-server written in Node based on grpc-js 1.3.2, this caused that GRPC-Calls fail with a PROTOCOL_ERROR.
Setting
resolver.Address.ServerName
in my resolver to the same thenresolver.Address.Addr
does not have any effect.The text was updated successfully, but these errors were encountered: