From cb8b1c57c413b3796c1eaf861e3eb368c42acdbb Mon Sep 17 00:00:00 2001 From: Lifan Yuan <1873861330@qq.com> Date: Tue, 14 Mar 2023 01:02:54 +0800 Subject: [PATCH] fix zip_downloader solving the certificate verification problem in data downloading --- OpenAttack/utils/zip_downloader.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/OpenAttack/utils/zip_downloader.py b/OpenAttack/utils/zip_downloader.py index 639e5ce9..26f7ae81 100644 --- a/OpenAttack/utils/zip_downloader.py +++ b/OpenAttack/utils/zip_downloader.py @@ -2,7 +2,7 @@ import zipfile import os from tqdm import tqdm - +import ssl def make_zip_downloader(URL : str, file_list=None, resource_name = None): """ @@ -28,7 +28,8 @@ def DOWNLOAD(path : str, source : str): else: name = resource_name - with urllib.request.urlopen(remote_url) as fin: + context = ssl._create_unverified_context() + with urllib.request.urlopen(remote_url, context=context) as fin: CHUNK_SIZE = 4 * 1024 total_length = int(fin.headers["content-length"]) with open(path + ".zip", "wb") as ftmp: