Created
April 5, 2023 11:12
-
-
Save rdkls/1a373915428109ab00a744d1ebbdf5a8 to your computer and use it in GitHub Desktop.
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" | |
do_fix ".vscode-insiders" | |
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