rancher-desktop: Starting RD gives Error: self signed certificate in certificate chain

Actual Behavior

Starting RD on MacOS goes through it’s startup. After about 5 min, it produces this error:

2023-07-12T18:44:31.521Z: Error starting lima: Error: self signed certificate in certificate chain
    at TLSSocket.onConnectSecure (node:_tls_wrap:1532:34)
    at TLSSocket.emit (node:events:527:28)
    at TLSSocket._finishInit (node:_tls_wrap:946:8)
    at ssl.onhandshakedone (node:_tls_wrap:727:12) {
  code: 'SELF_SIGNED_CERT_IN_CHAIN'
}

Steps to Reproduce

Start RD by clicking the RD icon in launchpad.

Result

2023-07-12T18:44:31.521Z: Error starting lima: Error: self signed certificate in certificate chain
    at TLSSocket.onConnectSecure (node:_tls_wrap:1532:34)
    at TLSSocket.emit (node:events:527:28)
    at TLSSocket._finishInit (node:_tls_wrap:946:8)
    at ssl.onhandshakedone (node:_tls_wrap:727:12) {
  code: 'SELF_SIGNED_CERT_IN_CHAIN'
}

Expected Behavior

RD to start without error.

Additional Information

No response

Rancher Desktop Version

1.9.1

Rancher Desktop K8s Version

1.27.3

Which container engine are you using?

moby (docker cli)

What operating system are you using?

macOS

Operating System / Build Version

Ventura 13.4.1

What CPU architecture are you using?

arm64 (Apple Silicon)

Linux only: what package format did you use to install Rancher Desktop?

None

Windows User Only

No response

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (12 by maintainers)

Most upvoted comments

Looks like the issue has been resolved, so I will close it.

Just for the record, I just ran into the same symptoms, but the cause was different: I had another VM running (using Lima), so the 6443 port was already in use by a different cluster, so Rancher Desktop could not forward the 6443 port to the host, and connections using the Rancher Desktop kubeconfig were connecting to the other VM. This of course caused the certificate mismatch because the other cluster cert was not signed by the Rancher Desktop CA.

Yep, when they hit that they get returned (individually) to the caller: https://github.com/rancher-sandbox/rancher-desktop/blob/3686c1aab004014c6608242885fdcf6dbd6e0dd7/pkg/rancher-desktop/main/networking/index.ts#L28-L29 And the agent is set to use those CAs: https://github.com/rancher-sandbox/rancher-desktop/blob/3686c1aab004014c6608242885fdcf6dbd6e0dd7/pkg/rancher-desktop/main/networking/index.ts#L36-L42 Eventually we end up using the agent when doing a fetch(): https://github.com/rancher-sandbox/rancher-desktop/blob/3686c1aab004014c6608242885fdcf6dbd6e0dd7/pkg/rancher-desktop/utils/fetch.ts#L124 We actually end up trapping SSL errors to better handle errors (for dealing with k3s, because the CA that uses is generated later): https://github.com/rancher-sandbox/rancher-desktop/blob/3686c1aab004014c6608242885fdcf6dbd6e0dd7/pkg/rancher-desktop/utils/fetch.ts#L71 So that would be a good spot to try to set a breakpoint and check if the agent in that scope has the correct CAs set.

On macOS, we basically run /usr/bin/security find-certificate -a -p to find the set of certificates; does that list your certificate? (The relevant code is at https://github.com/rancher-sandbox/rancher-desktop/blob/v1.14.2/pkg/rancher-desktop/main/networking/mac-ca.ts )

There’s also a chance that we’re screwing up actually adding the certificates; we set those certificates on the global HTTP(S) agent instance: https://github.com/rancher-sandbox/rancher-desktop/blob/v1.14.2/pkg/rancher-desktop/main/networking/index.ts#L27-L42 but we should be setting the correct agent at https://github.com/rancher-sandbox/rancher-desktop/blob/v1.14.2/pkg/rancher-desktop/utils/fetch.ts#L124