Visual Studio 2022中GitHub Copilot激活失败求助
问题描述
同一台笔记本上,GitHub Copilot在Visual Studio Code中正常运行,但在Visual Studio 2022中无法使用。已安装对应扩展,重启VS2022并加载项目后,弹出Copilot激活码连接弹窗,点击确定后输出窗口重复出现以下错误:
GitHub Copilot 1.84.0.1 (v1.84.0.1@760da3695) [DEBUG] [agent]
[2023-06-01T17:09:44.368Z] Agent service starting [DEBUG] [agent]
[2023-06-01T17:09:44.714Z] Telemetry initialized GitHub Copilot Agent
v1.84.0 [Error] An error occurred for
'RunOperation:SignInInitiateAsync':
StreamJsonRpc.RemoteInvocationException: Request signInInitiate failed
with message: self signed certificate in certificate chain at
StreamJsonRpc.JsonRpc.d__1511.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at GitHub.Copilot.CopilotClient.<RunOperation>d__201.MoveNext() [DEBUG]
[agent] [2023-06-01T17:09:52.281Z] Agent service starting [DEBUG]
[agent] [2023-06-01T17:09:52.337Z] Telemetry initialized [Error] An
error occurred for 'RunOperation:RunOperation':
StreamJsonRpc.RemoteInvocationException: Request signInInitiate failed
with message: self signed certificate in certificate chain at
StreamJsonRpc.JsonRpc.d__1511.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at GitHub.Copilot.CopilotClient.<RunOperation>d__201.MoveNext() [DEBUG]
[agent] [2023-06-01T17:09:53.585Z] Agent service starting [DEBUG]
[agent] [2023-06-01T17:09:53.620Z] Telemetry initialized NotSignedIn
[Error] An error occurred for 'RunOperation:SignInInitiateAsync':
StreamJsonRpc.RemoteInvocationException: Request signInInitiate failed
with message: self signed certificate in certificate chain at
StreamJsonRpc.JsonRpc.d__1511.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at GitHub.Copilot.CopilotClient.<RunOperation>d__201.MoveNext() [DEBUG]
[agent] [2023-06-01T17:10:08.313Z] Agent service starting [DEBUG]
[agent] [2023-06-01T17:10:08.346Z] Telemetry initialized [Error] An
error occurred for 'RunOperation:RunOperation':
StreamJsonRpc.RemoteInvocationException: Request signInInitiate failed
with message: self signed certificate in certificate chain at
StreamJsonRpc.JsonRpc.d__1511.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at GitHub.Copilot.CopilotClient.<RunOperation>d__201.MoveNext() [DEBUG]
[agent] [2023-06-01T17:10:08.957Z] Agent service starting [DEBUG]
[agent] [2023-06-01T17:10:08.971Z] Telemetry initialized NotSignedIn
已尝试将“选项 > GitHub Copilot > 接受不受信任的证书授权”设置为True,但问题仍未解决。
可行解决办法
方法1:导入自签名证书到Windows信任存储
- 定位到导致问题的自签名证书(多为公司内网代理证书)
- 打开控制面板 > 网络和 Internet > Internet 选项,切换至内容标签页,点击证书
- 在受信任的根证书颁发机构标签页,点击导入,跟随向导完成证书导入
- 重启Visual Studio 2022,重新尝试激活Copilot
方法2:配置Visual Studio使用系统代理设置
- 打开Visual Studio 2022,进入工具 > 选项 > 环境 > 网络
- 确认使用系统代理设置已勾选
- 若使用手动代理,确保代理地址、端口配置正确,并将GitHub相关域名加入白名单
- 重启Visual Studio后重试
方法3:更新并重置GitHub Copilot扩展
- 打开Visual Studio 2022,进入扩展 > 管理扩展
- 找到GitHub Copilot扩展,检查并安装可用更新
- 卸载Copilot扩展,重启Visual Studio后重新安装
- 安装完成后,进入工具 > 选项 > GitHub Copilot,确认接受不受信任的证书授权设为True,再次尝试登录
方法4:临时修改环境变量绕过证书验证
- 右键此电脑 > 属性 > 高级系统设置 > 环境变量
- 在系统变量中添加:
- 变量名:
NODE_TLS_REJECT_UNAUTHORIZED - 变量值:
0
- 变量名:
- 重启Visual Studio 2022后尝试登录
注意:此方法会降低系统安全性,仅建议测试环境使用,问题解决后请删除该环境变量
内容的提问来源于stack exchange,提问作者Kris van der Mast

