godaddy / kubernetes-client

Simplified Kubernetes API client for Node.js.
MIT License
962 stars 192 forks source link

Error: unable to verify the first certificate #688

Open minotaurrr opened 3 years ago

minotaurrr commented 3 years ago

Hi i thought this was related to the insecureSkipTlsVerify option in the client but setting it to true doesn't seem to fix the issue..

    const client = new Client({
      config: {
        url: CLUSTER_ENDPOINT,
        auth: {
          bearer: getBearerToken(CLUSTER_NAME),
        },
        insecureSkipTlsVerify: true,
      },
      version: '1.13',
    });

    const pods = await client.api.v1.namespaces(NAMESPACE).pods.get();
    const containerName = pods.body.items[0].spec.containers[0].name;
    const podName = pods.body.items[0].metadata.name;
    console.log(`Connecting to pod: ${podName}`);
    console.log(`Connecting to container: ${containerName}`);
    const res = await client.api.v1
      .namespaces(NAMESPACE)
      .pods(podName)
      .exec.post({
        qs: {
          command: ['ls', '-a'],
          container: containerName,
          stdout: true,
          stderr: true,
        },
      });

    console.log(res.body);
    console.log(res.messages);

I get this error when i run the above, any idea how to fix?

Error: unable to verify the first certificate
    at TLSSocket.onConnectSecure (_tls_wrap.js:1502:34)
    at TLSSocket.emit (events.js:314:20)
    at TLSSocket._finishInit (_tls_wrap.js:937:8)
    at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:711:12) {
  code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE',
  messages: []
}