GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: expose cert and key for mTLS by bcoe · Pull Request #1014 · googleapis/gax-nodejs

This repository was archived by the owner on Nov 18, 2025. It is now read-only.

Conversation

@bcoe

@bcoe bcoe commented May 26, 2021

Copy link
Copy Markdown

Allow cert and key to be passed to createSSL.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
bcoe
feat: expose cert and key for mTLS
624d8f2
@bcoe
bcoe requested a review from a team May 26, 2021 19:26
@google-cla google-cla Bot added the cla: yes This human has signed the Contributor License Agreement. label May 26, 2021
@bcoe
bcoe requested review from alexander-fenster, bshaffer and chingor13 May 26, 2021 19:26
bcoe
bcoe commented May 26, 2021
View reviewed changes
Comment thread src/clientInterface.ts
fallback?: boolean | 'rest' | 'proto';
apiEndpoint?: string;
// clientCertSource must return a tuple of cert and key, which
// are used to configure mTLS:

@bcoe bcoe May 26, 2021

Copy link
Copy Markdown
Author

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 method will actually be invoked in generated code.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@summer-ji-eng summer-ji-eng Jun 2, 2021

Copy link
Copy Markdown
Contributor

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.

Is workflow like this: a user can pass clientOptions with clientCertSource defined to construct a client. Then generator invoke this callback and to get cert and key.

Is that all generator need to do to support mTLS?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@bcoe bcoe Jun 3, 2021

Copy link
Copy Markdown
Author

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.

@summer-ji-eng I'll share the AIP. There's a couple environment variables we check for, and a well known file location (which might have information for connecting through mTLS).

I think this would make more sense in the generated code, potentially, than this layer?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@arithmetic1728 arithmetic1728 Jun 8, 2021

Copy link
Copy Markdown

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.

At the first glance, I think one possible design is:

For microgenerator, in the client initialization
(1) check GOOGLE_API_USE_CLENT_CERTIFICATE env var.

  • If it is not true, set _opts.cert = _opts.key = null
  • If it is true, there are 2 cases. If client_options.client_cert_source is not null, run it to produce cert/key; if it is null, then produce the default cert/key if exists. After that set _opts.cert and _opts.key. I think gax should provide APIs to check if default cert/key exists and produce them, since this is common code among all clients.

(2) check GOOGLE_API_USE_MTLS_ENDPOINT env var. Figure out the api endpoint to use, based on if user provided api endpoint via _opts.apiEndpoint, and this env var value, and if _opts.cert, _opts.key exists. Then set _opts.service_path to the right endpoint (regular or mtls)

For gax, use the code in this PR + the APIs for default cert/key

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
bcoe
bcoe commented May 26, 2021
View reviewed changes
Comment thread src/grpc.ts
const sslCreds = grpc.credentials.createSsl();
const sslCreds =
opts.cert && opts.key
? grpc.credentials.createSsl(

@bcoe bcoe May 26, 2021

Copy link
Copy Markdown
Author

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.

Method definition here:

https://github.com/grpc/grpc-node/blob/bf2e5cb1dd25e43f53605d8de2b8e082072ec23e/packages/grpc-js/src/channel-credentials.ts#L116

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Benjamin E. Coe added 3 commits May 27, 2021 14:07
Benjamin E. Coe
Merge branch 'master' into mtls
df80730
Benjamin E. Coe
Merge branch 'master' into mtls
b75f837
Benjamin E. Coe
Merge branch 'master' into mtls
0c537e8
summer-ji-eng
summer-ji-eng approved these changes Jun 8, 2021
View reviewed changes
@bcoe
bcoe merged commit f025fc1 into master Jun 9, 2021
@bcoe
bcoe deleted the mtls branch June 9, 2021 17:37
gcf-merge-on-green Bot pushed a commit that referenced this pull request Jun 10, 2021
@release-please
chore: release 2.15.0 (#1023)
471f238
🤖 I have created a release \*beep\* \*boop\*
---
## [2.15.0](https://www.github.com/googleapis/gax-nodejs/compare/v2.14.1...v2.15.0) (2021-06-10)


### Features

* expose cert and key for mTLS ([#1014](https://www.github.com/googleapis/gax-nodejs/issues/1014)) ([f025fc1](https://www.github.com/googleapis/gax-nodejs/commit/f025fc155c505792bc74929a7803a2df63c331cd))
---


This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

@alexander-fenster alexander-fenster Awaiting requested review from alexander-fenster
@bshaffer bshaffer Awaiting requested review from bshaffer
@chingor13 chingor13 Awaiting requested review from chingor13
2 more reviewers
@arithmetic1728 arithmetic1728 arithmetic1728 left review comments
@summer-ji-eng summer-ji-eng summer-ji-eng approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@bcoe @summer-ji-eng @arithmetic1728
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.