-
Notifications
You must be signed in to change notification settings - Fork 557
Open
Description
Describe the bug
I'm using @kubernetes/client-node
to send HTTP requests to an apiserver with a self-signed certificate. I can't provide the CA, so I'm trying to use NODE_TLS_REJECT_UNAUTHORIZED=0 to skip the tls verification. However, this doesn't work.
Client Version
1.3.0
Server Version
N/A
To Reproduce
Steps to reproduce the behavior:
import * as k8s from '@kubernetes/client-node';
import fetch from 'node-fetch';
const url = "https://localhost:443"; // server with self-signed certificate
const kc = new k8s.KubeConfig();
const res = await fetch(url, await kc.applyToFetchOptions({}));
console.log(res.status);
NODE_TLS_REJECT_UNAUTHORIZED=0 node test.js
(node:211892) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
(Use `node --trace-warnings ...` to show where the warning was created)
/home/tw/code/javascript/node_modules/node-fetch/lib/index.js:1501
reject(new FetchError(`request to ${request.url} failed, reason: ${err.message}`, 'system', err));
^
FetchError: request to https://localhost:8443/ failed, reason: self-signed certificate; if the root CA is installed locally, try running Node.js with --use-system-ca
at ClientRequest.<anonymous> (/home/0x5457/code/test/node_modules/node-fetch/lib/index.js:1501:11)
at ClientRequest.emit (node:events:507:28)
at emitErrorEvent (node:_http_client:104:11)
at TLSSocket.socketErrorListener (node:_http_client:518:5)
at TLSSocket.emit (node:events:507:28)
at emitErrorNT (node:internal/streams/destroy:170:8)
at emitErrorCloseNT (node:internal/streams/destroy:129:3)
at process.processTicksAndRejections (node:internal/process/task_queues:90:21) {
type: 'system',
errno: 'DEPTH_ZERO_SELF_SIGNED_CERT',
code: 'DEPTH_ZERO_SELF_SIGNED_CERT'
}
Expected behavior
Print status code 200
Environment (please complete the following information):
- OS: Ubuntu 24.04
- Node.js version v24.4.1
Metadata
Metadata
Assignees
Labels
No labels