diff options
author | Philipp Hagemeister <phihag@phihag.de> | 2013-05-04 12:19:02 +0200 |
---|---|---|
committer | Philipp Hagemeister <phihag@phihag.de> | 2013-05-04 12:22:56 +0200 |
commit | ea6d901e51c71714eb0f1c34594e2f50e20c7d0d (patch) | |
tree | db0eb3300d820fa2e7019458f1381f751c3729ec /youtube_dl/utils.py | |
parent | 4539dd30e6c00a50760094e7a41744843d659cb1 (diff) |
Add --no-check-certificate (#814)
Diffstat (limited to 'youtube_dl/utils.py')
-rw-r--r-- | youtube_dl/utils.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index 4ec0ebfe1..f2342b10a 100644 --- a/youtube_dl/utils.py +++ b/youtube_dl/utils.py @@ -438,6 +438,20 @@ def formatSeconds(secs): else: return '%d' % secs +def make_HTTPS_handler(opts): + if sys.version_info < (3,2): + # Python's 2.x handler is very simplistic + return compat_urllib_request.HTTPSHandler() + else: + import ssl + context = ssl.SSLContext(ssl.PROTOCOL_SSLv23) + context.set_default_verify_paths() + + context.verify_mode = (ssl.CERT_NONE + if opts.no_check_certificate + else ssl.CERT_REQUIRED) + return compat_urllib_request.HTTPSHandler(context=context) + class ExtractorError(Exception): """Error during info extraction.""" def __init__(self, msg, tb=None): |