[ssl] Correct connect creation
authorPhilipp Hagemeister <phihag@phihag.de>
Thu, 15 Jan 2015 01:06:48 +0000 (02:06 +0100)
committerPhilipp Hagemeister <phihag@phihag.de>
Thu, 15 Jan 2015 01:06:50 +0000 (02:06 +0100)
We want to authenticate the server, see https://docs.python.org/dev/library/ssl.html#ssl.Purpose.SERVER_AUTH .

youtube_dl/utils.py

index 38c18c1273b1f6df3fa61d4362a8ebbf0e7bfac0..2546fa45d21599e89a71ee7843cd443585c4d1f9 100644 (file)
@@ -399,8 +399,9 @@ def formatSeconds(secs):
 def make_HTTPS_handler(params, **kwargs):
     opts_no_check_certificate = params.get('nocheckcertificate', False)
     if hasattr(ssl, 'create_default_context'):  # Python >= 3.4 or 2.7.9
-        context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
+        context = ssl.create_default_context(ssl.Purpose.SERVER_AUTH)
         if opts_no_check_certificate:
+            context.check_hostname = False
             context.verify_mode = ssl.CERT_NONE
         try:
             return YoutubeDLHTTPSHandler(params, context=context, **kwargs)