copilot.el icon indicating copy to clipboard operation
copilot.el copied to clipboard

How to use with self-signed certificates?

Open aramirezreyes opened this issue 9 months ago • 1 comments

Hi! Thanks for the great tool.

Summary

I am facing an error when using copilot.el . The error has to do with using self-signed certificates, which prevent the communication with copilot.

  • A good explanation of how this happens is given here: https://stackoverflow.com/a/71973332
  • A similar error in the vscode extension is solved by installing this extension. https://github.com/linhmtran168/mac-ca-vscode/tree/main
  • That one is based on this extension to allow node.js to honor those certificates: https://github.com/jfromaniello/mac-ca

The error message

This appears in the *copilot-language-server-log whenever the extension tries to communicate with the github servers, it it basically does not work.

[ghostText] Error on ghost text request: FetchError: The pending stream has been canceled (caused by: self-signed certificate in certificate chain)
    at fetch (~/.config/emacs/.cache/copilot/lib/node_modules/@github/copilot-language-server/node_modules/@adobe/helix-fetch/src/fetch/index.js:99:11)
    at processTicksAndRejections (node:internal/process/task_queues:105:5)
    at cachingFetch (~/.config/emacs/.cache/copilot/lib/node_modules/@github/copilot-language-server/node_modules/@adobe/helix-fetch/src/fetch/index.js:288:16)
    at UT.fetch (~/.config/emacs/.cache/copilot/lib/node_modules/@github/copilot-language-server/lib/src/network/helix.ts:94:22)
    at IS.fetchWithParameters (~/.config/emacs/.cache/copilot/lib/node_modules/@github/copilot-language-server/lib/src/openai/fetch.ts:834:26)
    at IS.fetchAndStreamCompletions (~/.config/emacs/.cache/copilot/lib/node_modules/@github/copilot-language-server/lib/src/openai/fetch.ts:528:26)
    at genericGetCompletionsFromNetwork (~/.config/emacs/.cache/copilot/lib/node_modules/@github/copilot-language-server/lib/src/ghostText/ghostText.ts:161:21)
    at ~/.config/emacs/.cache/copilot/lib/node_modules/@github/copilot-language-server/lib/src/ghostText/ghostText.ts:1011:31
    at getGhostText (~/.config/emacs/.cache/copilot/lib/node_modules/@github/copilot-language-server/lib/src/ghostText/ghostText.ts:1155:16)
    at getInlineCompletionsResult (~/.config/emacs/.cache/copilot/lib/node_modules/@github/copilot-language-server/lib/src/inlineCompletion.ts:30:20) {
  type: 'system',
  _name: 'FetchError',
  code: 'ERR_HTTP2_STREAM_CANCEL',
  errno: undefined,
  erroredSysCall: undefined
}
[default] Error sending telemetry FetchError: The pending stream has been canceled (caused by: self-signed certificate in certificate chain)
    at fetch (~/.config/emacs/.cache/copilot/lib/node_modules/@github/copilot-language-server/node_modules/@adobe/helix-fetch/src/fetch/index.js:99:11)
    at processTicksAndRejections (node:internal/process/task_queues:105:5)
    at cachingFetch (~/.config/emacs/.cache/copilot/lib/node_modules/@github/copilot-language-server/node_modules/@adobe/helix-fetch/src/fetch/index.js:288:16)
    at UT.fetch (~/.config/emacs/.cache/copilot/lib/node_modules/@github/copilot-language-server/lib/src/network/helix.ts:94:22) {
  type: 'system',
  _name: 'FetchError',
  code: 'ERR_HTTP2_STREAM_CANCEL',
  errno: undefined,
  erroredSysCall: undefined
}

What I have tried.

  1. I tried installing the mac-ca certificates from here https://github.com/jfromaniello/mac-ca into the node version used by copilot.el
  2. Then I modified ~/.config/emacs/.cache/copilot/lib/node_modules/@github/copilot-language-server/dist/language-server.js By adding this to the shebang #!/usr/bin/env node --require mac-ca/register

But unfortunately no luck. Do you have any pointers for this?

aramirezreyes avatar May 21 '25 09:05 aramirezreyes

~probably insecure but you can try setting env NODE_TLS_REJECT_UNAUTHORIZED=0~ nvm

knilink avatar May 21 '25 16:05 knilink