Skip to content

feat(grpc): add support for authority pseudo-header #4898

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Oursin
Copy link

@Oursin Oursin commented Jul 7, 2025

What?

This PR adds support for setting the authority pseudo-header when sending gRPC requests.

Why?

This MR is similar to #3454, which was not accepted because the feature was supposed to work without changes using the dns://authority/endpoint syntax.

The company I work at uses gRPC services with TLS certificates matching the gRPC service name. So for example we would have a gRPC service company.test.v1 hosted on a machine reachable from test-v1.internal.company.com, but exposing a certificate signed for company.test.v1.

I tried using the dns:/// syntax like this:

client.connect('dns://company.test.v1/test-v1.internal.company.com:443', {timeout: '5s', tls: TLSParams});

But I end up with this error, the same as if I was simply trying to connect without the dns:/// syntax.

context deadline exceeded: connection error: desc = "transport: authentication handshake failed: tls: failed to verify certificate: x509: certificate is valid for company.test.v1, not test-v1.internal.company.com

I have a workaround by configuring my /etc/hosts file so that the addess in connect is company.test.v1 but I would prefer if it was a k6 parameter directly.

With the changes made in this MR i can connect like this:

client.connect('test-v1.internal.company.com:443', {timeout: '5s', authority: 'company.test.v1', tls: TLSParams});

Which allows the TLS handshake to work properly.

Checklist

  • I have performed a self-review of my code.
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have added tests for my changes.
  • I have run linter and tests locally (make check) and all pass.

Checklist: Documentation (only for k6 maintainers and if relevant)

Please do not merge this PR until the following items are filled out.

  • I have added the correct milestone and labels to the PR.
  • I have updated the release notes: link
  • I have updated or added an issue to the k6-documentation: grafana/k6-docs#NUMBER if applicable
  • I have updated or added an issue to the TypeScript definitions: grafana/k6-DefinitelyTyped#NUMBER if applicable

Related PR(s)/Issue(s)

#3454

@Oursin Oursin requested a review from a team as a code owner July 7, 2025 09:55
@Oursin Oursin requested review from inancgumus and AgnesToulet and removed request for a team July 7, 2025 09:55
@CLAassistant
Copy link

CLAassistant commented Jul 7, 2025

CLA assistant check
All committers have signed the CLA.

@AgnesToulet AgnesToulet requested a review from codebien July 17, 2025 08:46
@andrewslotin andrewslotin removed the request for review from inancgumus July 17, 2025 12:54
Copy link
Contributor

@codebien codebien left a comment

Choose a reason for hiding this comment

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

Hey @Oursin, thanks for taking care of this. 🎉 Much appreciated 🙇 We plan to merge as soon as we get a green CI.

Copy link
Contributor

@AgnesToulet AgnesToulet left a comment

Choose a reason for hiding this comment

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

I've tested it and it works great, thank you for your contribution! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants