CopilotForXcode icon indicating copy to clipboard operation
CopilotForXcode copied to clipboard

[Help Wanted]: How to use self-signed certificates with GitHub Copilot

Open jerrylcliu opened this issue 1 year ago • 5 comments

Before Reporting

  • [X] I have checked FAQ, and there is no solution to my issue
  • [X] I have searched the existing issues, and there is no existing issue for my issue

Describe your issue

Using copilot behind a Corporate network, will get this error: self signed certificate in certificate chain. Behind a normal network, CopilotForXcode works well. In VSCode, the extension "Mac CA VScode" can solve this; How to solve this error in CopilotForXcode?

jerrylcliu avatar Mar 11 '24 12:03 jerrylcliu

You can try:

  1. Add NODE_OPTIONS=--use-openssl-ca to ~/.bashrc.
  2. Change "Run node with" to /bin/bash -i -l, so that the app will read ~/.bashrc for configurations.
  3. Restart the service and host app to restart the language server.

I have tested that with this change, I can MITM the requests to https://api.github.com/copilot_internal/v2/token with a self-signed certificate.

The GitHub Copilot language server doesn't allow self-signed certificate of copilot-proxy.githubusercontent.com (for non-enterprise users?), but it works If I use Mac CA VSCode, so I am not sure if it will work.

intitni avatar Mar 11 '24 13:03 intitni

Nailed it!

  1. Go to ~/Library/Application Support/com.intii.CopilotForXcode/GitHub Copilot/executable/copilot/dist
  2. Rename agent.js to _agent.js.
  3. Download the following file, save it to the dist folder, and rename it to agent.js. The file is a javascript version of Mac CA VSCode.
  4. Restart the app to restart the language server.

agent.js.txt

I will try to include it in the app in the next release.

intitni avatar Mar 11 '24 14:03 intitni

Nailed it!

  1. Go to ~/Library/Application Support/com.intii.CopilotForXcode/GitHub Copilot/executable/copilot/dist
  2. Rename agent.js to _agent.js.
  3. Download the following file, save it to the dist folder, and rename it to agent.js. The file is a javascript version of Mac CA VSCode.
  4. Restart the app to restart the language server.

agent.js.txt

I will try to include it in the app in the next release.

Thanks for your reply. I try this, it does not work. The error is still "self signed certificate in certificate chain". Suggestion cannot show, it works well behind normal network

jerrylcliu avatar Mar 12 '24 03:03 jerrylcliu

It should work. Did you restart the service app? Where did you get the error message? I have never seen the message before.

Screenshot 2024-03-12 at 12 59 50 Screenshot 2024-03-12 at 12 55 38

intitni avatar Mar 12 '24 05:03 intitni

It should work. Did you restart the service app? Where did you get the error message? I have never seen the message before.

Screenshot 2024-03-12 at 12 59 50 Screenshot 2024-03-12 at 12 55 38

It has now taken effect. I had already restarted the app before my last reply, but it didn't work at that time. Just now, after restarting a few more times and opening Xcode, I found that it has indeed taken effect. The error message is from console.app - CopilotForXcodeExtensionService, now it doesn't show😂

jerrylcliu avatar Mar 12 '24 06:03 jerrylcliu

Released in 0.33.1 beta

intitni avatar May 22 '24 21:05 intitni

Released in 0.33.1

intitni avatar May 27 '24 08:05 intitni