googleapis / googleapis/google-cloud-node

IAP service account certificate error

Open
#7,749 1 comment 0 reactions 0 assignees View on GitHub
library: google-cloud-node-core priority: p2 type: bug
Dominant language
TypeScript
Stars
3.2k
Forks
712
Avg merge
2d 3h
Merged PRs (30d)
99

Description

#### Environment details

- OS: MacOs/Google Cloud Functions
- Node.js version: 16
- npm version: 9.5.0
- `google-auth-library` version: 8.7.0

#### Steps to reproduce

1. Create an IAP
2. Create a client like [here](https://cloud.google.com/iap/docs/authentication-howto#obtaining_an_oidc_token_for_the_default_service_account), filling in your values

The idtoken will be fetched without issues. I also verified that the token works by using it in a curl request. However, the client throws the following error:

```
FetchError: request to https://my-protected-domain.com/mypage failed, reason: unable to verify the first certificate
at ClientRequest. (//node_modules/node-fetch/lib/index.js:1491:11)
at ClientRequest.emit (node:events:513:28)
at TLSSocket.socketErrorListener (node:_http_client:502:9)
at TLSSocket.emit (node:events:513:28)
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
type: 'system',
errno: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE',
code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE',
...
```
It is interesting to note that this happens in the nodejs client and the python client, but not in the Golang client. For the python client, setting `verify=False` in the request solves the issue (in an insecure way).
The service account is verified by a keypair via the `GOOGLE_APPLICATION_CREDENTIALS` environment variable.
This happens both locally and in a cloud function.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.