Skip to content

Commit

Permalink
download: allow to disable SSL certificate verification
Browse files Browse the repository at this point in the history
via the same environment variable that git uses to do the same thing.
  • Loading branch information
glandium committed Aug 1, 2024
1 parent 5f95716 commit e363b97
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions download.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,19 @@ def get_release_url(system, machine, tag):
def download(url, system, binary_path):
print("Downloading from %s..." % url, file=sys.stderr)
if os.environ.get("GIT_SSL_NO_VERIFY"):
import ssl
context = ssl.create_default_context()
context.check_hostname = False
context.verify_mode = ssl.CERT_NONE
else:
context = None
try:
reader = urlopen(url)
reader = urlopen(url, context=context)
except HTTPError:
# Try again, just in case
try:
reader = urlopen(url)
reader = urlopen(url, context=context)
except HTTPError as e:
print("Download failed with status code %d\n" % e.code, file=sys.stderr)
print(
Expand Down

0 comments on commit e363b97

Please sign in to comment.