Skip to content

Commit 43e30bd

Browse files
author
Kevin D Smith
committed
Add ssl support to uploads
1 parent 749aeee commit 43e30bd

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

swat/cas/connection.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1590,14 +1590,20 @@ def upload(self, data, importoptions=None, casout=None, **kwargs):
15901590
elif data.startswith('http://') or \
15911591
data.startswith('https://') or \
15921592
data.startswith('ftp://'):
1593+
import certifi
1594+
import ssl
15931595
import tempfile
15941596
from six.moves.urllib.request import urlopen
15951597
from six.moves.urllib.parse import urlparse
15961598
parts = urlparse(data)
15971599
ext = os.path.splitext(parts.path)[-1].lower()
15981600
with tempfile.NamedTemporaryFile(delete=False, suffix=ext) as tmp:
15991601
delete = True
1600-
tmp.write(urlopen(data).read())
1602+
tmp.write(
1603+
urlopen(
1604+
data,
1605+
context=ssl.create_default_context(cafile=certifi.where())
1606+
).read())
16011607
filename = tmp.name
16021608
if parts.path:
16031609
name = os.path.splitext(parts.path.split('/')[-1])[0]

0 commit comments

Comments
 (0)