Last active
November 29, 2024 12:45
-
-
Save sarimarton/55779cf95028860ea2126e61a6b377d0 to your computer and use it in GitHub Desktop.
Fix Github Copilot in dealing with self-signed certificates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# [2023-05-25] Added Copilot Chat, and VSCode Insiders | |
# [2023-05-20] Add VSCode Insiders variant | |
# [2023-02-22] Added Copilot Labs | |
# Fix Github Co-pilot self-signed cert problem | |
# See: https://github.com/orgs/community/discussions/8866#discussioncomment-3517831 | |
# Note | |
# | |
# To make Github Copilot/Nightly/Labs/Chat work, you might need additional | |
# steps. | |
# ---------------------------------------------- | |
# - The bash script is solid. Keep the fixing command run on shell start. | |
# - Sign out of github from vscode, lower left corner. Ref: | |
# https://docs.github.com/en/copilot/troubleshooting-github-copilot/troubleshooting-common-issues-with-github-copilot#error-github-copilot-could-not-connect-to-server-extension-activation-failed | |
# - Reload window, sign back in, make sure you're using the Chrome window with | |
# the right profile (with which you're logged in to the right account), reload | |
# window | |
# - Check VSCode Output pane | |
# - if EAI_AGAIN error happens, in particular under WSL, this worked: | |
# - sudo sh -c "echo nameserver 8.8.8.8 > /etc/resolv.conf" | |
# - Ref: https://github.com/community/community/discussions/19499#discussioncomment-5026421 | |
# - As for Labs/Chat, check their webpage, there might be a waiting list, or | |
# terms to accept before you get access. The error message in the Output pane | |
# should give you a hint about it. | |
fix_github_copilot() { | |
local silent_mode=$1 | |
apply_patch() { | |
local vscode_dir=$1 | |
local regex_pattern=$2 | |
local extension_name=$3 | |
local extensions_path="$HOME/${vscode_dir}/extensions" | |
local copilot_dir=$(ls "${extensions_path}" | grep -E "${regex_pattern}" | sort -V | tail -n1) || return | |
local extension_filepath="${extensions_path}/${copilot_dir}/dist/extension.js" | |
if [[ -f "$extension_filepath" ]]; then | |
if [[ $silent_mode != 'silent' ]]; then | |
echo "Found $extension_name extension, applying 'rejectUnauthorized' patches to '$extension_filepath'" | |
fi | |
perl -pi -e 's/,rejectUnauthorized:[a-z]}(?!})/,rejectUnauthorized:false}/g' ${extension_filepath} || echo "Perl patch failed" | |
sed -i.bak 's/d={...l,/d={...l,rejectUnauthorized:false,/g' ${extension_filepath} || echo "Sed patch failed" | |
fi | |
} | |
perform_fix() { | |
if [[ -d "$HOME/$1" ]]; then | |
apply_patch "$1" "github.copilot-[0-9].*" "Copilot" | |
apply_patch "$1" "github.copilot-nightly-[0-9].*" "Copilot Nightly" | |
apply_patch "$1" "github.copilot-labs-[0-9].*" "Copilot Labs" | |
apply_patch "$1" "github.copilot-chat-[0-9].*" "Copilot Chat" | |
fi | |
} | |
perform_fix ".vscode" | |
perform_fix ".vscode-server" | |
perform_fix ".vscode-insiders" | |
perform_fix ".vscode-server-insiders" | |
unset -f apply_patch | |
unset -f perform_fix | |
} | |
fix_github_copilot silent |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It would appear they have patched this out now.