Add requests build dependency, and use requests to download Tor Browser in get-tor-osx.py and get-tor-windows.py, because I was running into SSL certificate verification issues downloading using urllib

This commit is contained in:
Micah Lee 2018-06-18 12:53:27 -07:00
parent 97acfccf09
commit 19c2193a49
4 changed files with 24 additions and 12 deletions

View file

@ -24,8 +24,13 @@ In order to avoid a Windows gnupg dependency, I manually verify the signature
and hard-code the sha256 hash.
"""
import inspect, os, sys, hashlib, shutil, subprocess
import urllib.request
import inspect
import os
import sys
import hashlib
import shutil
import subprocess
import requests
def main():
exe_url = 'https://archive.torproject.org/tor-package-archive/torbrowser/7.5.5/torbrowser-install-7.5.5_en-US.exe'
@ -44,10 +49,9 @@ def main():
# Make sure the zip is downloaded
if not os.path.exists(exe_path):
print("Downloading {}".format(exe_url))
response = urllib.request.urlopen(exe_url)
exe_data = response.read()
open(exe_path, 'wb').write(exe_data)
exe_sha256 = hashlib.sha256(exe_data).hexdigest()
r = requests.get(exe_url)
open(exe_path, 'wb').write(r.content)
exe_sha256 = hashlib.sha256(r.content).hexdigest()
else:
exe_data = open(exe_path, 'rb').read()
exe_sha256 = hashlib.sha256(exe_data).hexdigest()