|
50 | 50 | from argparse import RawDescriptionHelpFormatter
|
51 | 51 | # unify Python 2 and 3
|
52 | 52 | if sys.version_info[0] == 2:
|
53 |
| - import urllib2 as ulr |
54 | 53 | import urllib as ulp
|
55 | 54 | import cPickle as pickle
|
56 | 55 | pickleload = pickle.load
|
57 | 56 | elif sys.version_info[0] == 3:
|
58 |
| - import urllib.request as ulr |
59 | 57 | import urllib.parse as ulp
|
60 | 58 | import pickle
|
61 | 59 | unicode = str
|
|
75 | 73 | jsondump, jsonload, formatex, rb,
|
76 | 74 | joinpath, get_pcs_path, print_pcs_list, str2bool, str2int,
|
77 | 75 | human_size, interpret_size, ls_time, ls_type,
|
78 |
| - makedir, removedir, copyfile, movefile, removefile, getfilesize, |
| 76 | + makedir, removedir, movefile, removefile, getfilesize, |
79 | 77 | MyPrettyPrinter)
|
80 | 78 | from .chkreq import (check_requirements, CheckResult)
|
81 | 79 | from .requester import RequestsRequester
|
@@ -167,26 +165,6 @@ def migratesettings():
|
167 | 165 |
|
168 | 166 | return result
|
169 | 167 |
|
170 |
| - def getcertfile(self): |
171 |
| - result = const.ENoError |
172 |
| - if not os.path.exists(self.__certspath): |
173 |
| - if os.path.exists(const.ByPyCertsFileName): |
174 |
| - result = copyfile(const.ByPyCertsFileName, self.__certspath) |
175 |
| - else: |
176 |
| - try: |
177 |
| - # perform a simple download from github |
178 |
| - CACertUrl = 'https://raw.githubusercontent.com/houtianze/bypy/master/bypy.cacerts.pem' |
179 |
| - resp = ulr.urlopen(CACertUrl) |
180 |
| - with io.open(self.__certspath, 'wb') as f: |
181 |
| - f.write(resp.read()) |
182 |
| - except IOError as ex: |
183 |
| - perr("Fail download CA Certs to '{}'.\n{}".format( |
184 |
| - self.__certspath, formatex(ex))) |
185 |
| - |
186 |
| - result = const.EDownloadCerts |
187 |
| - |
188 |
| - return result |
189 |
| - |
190 | 168 | # TODO: save settings here?
|
191 | 169 | def quit(retcode = const.ENoError):
|
192 | 170 | # saving is the most important
|
@@ -264,9 +242,7 @@ def __init__(self,
|
264 | 242 | perr("Error loading settings: {}, using default settings".format(formatex(ex)))
|
265 | 243 | self.__hashcachepath = configdir + os.sep + const.HashCacheFileName
|
266 | 244 | cached.hashcachepath = self.__hashcachepath
|
267 |
| - self.__certspath = configdir + os.sep + const.ByPyCertsFileName |
268 |
| - # it doesn't matter if it failed, we can disable SSL verification anyway |
269 |
| - self.getcertfile() |
| 245 | + self.__certspath = os.path.join(os.path.dirname(__file__), const.ByPyCertsFileName) |
270 | 246 |
|
271 | 247 | self.__requester = requester
|
272 | 248 | self.__apikey = apikey
|
@@ -308,15 +284,13 @@ def __init__(self,
|
308 | 284 | self.__followlink = followlink;
|
309 | 285 | self.__rapiduploadonly = rapiduploadonly
|
310 | 286 |
|
311 |
| - # TODO: properly fix this InsecurePlatformWarning |
312 |
| - checkssl = False |
313 | 287 | self.__checkssl = checkssl
|
314 | 288 | if self.__checkssl:
|
315 | 289 | # sort of undocumented by requests
|
316 | 290 | # http://stackoverflow.com/questions/10667960/python-requests-throwing-up-sslerror
|
317 | 291 | if cacerts is not None:
|
318 | 292 | if os.path.isfile(cacerts):
|
319 |
| - self.__checkssl = cacerts |
| 293 | + self.__certspath = cacerts |
320 | 294 | else:
|
321 | 295 | perr("Invalid CA Bundle '{}' specified")
|
322 | 296 |
|
@@ -2990,7 +2964,7 @@ def getparser():
|
2990 | 2964 | dest="checkssl", action="store_false",
|
2991 | 2965 | help="DON'T verify host SSL cerificate")
|
2992 | 2966 | parser.add_argument(const.CaCertsOption,
|
2993 |
| - dest="cacerts", |
| 2967 | + dest="cacerts", default=None, |
2994 | 2968 | help="Specify the path for CA Bundle [default: %(default)s]")
|
2995 | 2969 | parser.add_argument("--mirror",
|
2996 | 2970 | dest="mirror", default=None,
|
|
0 commit comments