-
-
Save s1lvester/380c316b8439bf29884518bcc19c3a76 to your computer and use it in GitHub Desktop.
Fix Github Copilot in dealing with self-signed certificates
This file contains 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
# Fix Github Co-pilot self-signed cert problem | |
# See: https://github.com/orgs/community/discussions/8866#discussioncomment-3517831 | |
# The script is modified to handle .vscode-server too (in WSL2) | |
fix_github_copilot() { | |
patch_ext() { | |
_VSCODEDIR=$1 | |
_EXTENSIONSPATH="$HOME/${_VSCODEDIR}/extensions" | |
_RE=$2 | |
_NAME=$3 | |
_COPILOTDIR=$(ls "${_EXTENSIONSPATH}" | grep -E "${_RE}" | sort -V | tail -n1) | |
_EXTENSIONFILEPATH="${_EXTENSIONSPATH}/${_COPILOTDIR}/dist/extension.js" | |
if [[ -f "$_EXTENSIONFILEPATH" ]]; then | |
echo "Found $_NAME extension, applying 'rejectUnauthorized' patches to '$_EXTENSIONFILEPATH'" | |
perl -pi -e 's/,rejectUnauthorized:[a-z]}(?!})/,rejectUnauthorized:false}/g' ${_EXTENSIONFILEPATH} | |
sed -i.bak 's/d={...l,/d={...l,rejectUnauthorized:false,/g' ${_EXTENSIONFILEPATH} | |
fi | |
} | |
do_fix() { | |
if [[ -d "$HOME/$1" ]]; then | |
patch_ext "$1" "github.copilot-[0-9].*" "Copilot" | |
patch_ext "$1" "github.copilot-nightly-[0-9].*" "Copilot Nightly" | |
patch_ext "$1" "github.copilot-labs-[0-9].*" "Copilot Labs" | |
fi | |
} | |
do_fix ".vscode" | |
do_fix ".vscode-server" | |
unset -f do_fix | |
unset -f patch_ext | |
} | |
fix_github_copilot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment