Changes between Version 1 and Version 2 of Ticket #55150, comment 4


Ignore:
Timestamp:
Oct 23, 2017, 5:17:33 PM (7 years ago)
Author:
carlosfamilia (Carlos Familia)
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #55150, comment 4

    v1 v2  
    55This rolls back for the previous behaviour, however it does not check the certificates, I am not sure if you want to implement it like this or a more safe approach. Nevertheless the code needing changes is here identified:
    66
    7 
    87{{{
    9 *** internal.py Mon Oct 23 17:28:36 2017
    10 --- internal.py.old     Thu Mar  9 00:40:30 2017
    11 ***************
    12 *** 3,9 ****
    13  
    14   import os
    15   import sys
    16 + import ssl
    17   cmd = sys.modules["pymol.cmd"]
    18   from pymol import _cmd
    19   import threading
    20 --- 3,8 ----
    21 ***************
    22 *** 317,326 ****
    23           if not is_string(finfo):
    24               handle = finfo
    25           elif '://' in finfo:
    26 +             context = ssl._create_unverified_context()
    27               req = urllib2.Request(finfo,
    28                       headers={'User-Agent': 'PyMOL/' + _self.get_version()[0]})
    29 !             handle = urllib2.urlopen(req, context=context)
    30           else:
    31               handle = open(finfo, 'rb')
    32           contents = handle.read()
     8--- modules/pymol/internal.py   2017-03-09 00:40:30.000000000 +0000
     9+++ internal.py 2017-10-23 17:28:36.000000000 +0100
     10@@ -3,6 +3,7 @@
     11 
     12 import os
     13 import sys
     14+import ssl
     15 cmd = sys.modules["pymol.cmd"]
     16 from pymol import _cmd
     17 import threading
     18@@ -316,9 +317,10 @@
     19         if not is_string(finfo):
     20             handle = finfo
     21         elif '://' in finfo:
     22+            context = ssl._create_unverified_context()
     23             req = urllib2.Request(finfo,
     24                     headers={'User-Agent': 'PyMOL/' + _self.get_version()[0]})
     25-            handle = urllib2.urlopen(req)
     26+            handle = urllib2.urlopen(req, context=context)
     27         else:
     28             handle = open(finfo, 'rb')
     29         contents = handle.read()
    3330}}}
    3431
    3532{{{
    36 *** plugins/repository.py       Mon Oct 23 17:32:35 2017
    37 --- plugins/repository.py.old   Wed Apr 26 14:08:45 2017
    38 ***************
    39 *** 11,17 ****
    40   from __future__ import print_function
    41  
    42   import sys
    43 + import ssl
    44   if sys.version_info[0] > 2:
    45       import urllib.request as urllib2
    46       from urllib.parse import urlparse
    47 --- 11,16 ----
    48 ***************
    49 *** 32,40 ****
    50       not change that.
    51       '''
    52       from . import pref_get
    53 !     context = ssl._create_unverified_context()
    54       timeout = pref_get('network_timeout', 10.0)
    55 !     return urllib2.urlopen(url, timeout=timeout, context=context)
    56  
    57  
    58   def urlreadstr(url, encoding='iso-8859-1'):
     33--- modules/pymol/plugins/repository.py 2017-04-26 14:08:45.000000000 +0100
     34+++ plugins/repository.py       2017-10-23 17:32:35.000000000 +0100
     35@@ -11,6 +11,7 @@
     36 from __future__ import print_function
     37 
     38 import sys
     39+import ssl
     40 if sys.version_info[0] > 2:
     41     import urllib.request as urllib2
     42     from urllib.parse import urlparse
     43@@ -31,9 +32,9 @@
     44     not change that.
     45     '''
     46     from . import pref_get
     47
     48+    context = ssl._create_unverified_context()
     49     timeout = pref_get('network_timeout', 10.0)
     50-    return urllib2.urlopen(url, timeout=timeout)
     51+    return urllib2.urlopen(url, timeout=timeout, context=context)
     52 
     53 
     54 def urlreadstr(url, encoding='iso-8859-1'):
    5955}}}