Skip to content

Commit 09fd15b

Browse files
committed
Use certifi for SSL certificates
Certifi keeps an up-to-date list of certs, and makes it easier to inject extra certificates when needed. We often run in to SSL issues when using the LNT client to submit data. This will fix that.
1 parent 99ef19c commit 09fd15b

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lnt/util/ServerUtil.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
import urllib.error
1111
import contextlib
1212
import json
13-
13+
import ssl
14+
import certifi
1415
import lnt.server.instance
1516

1617
# FIXME: I used to maintain this file in such a way that it could be used
@@ -44,7 +45,8 @@ def submitFileToServer(url, file, select_machine=None, merge_run=None):
4445
headers = {'Accept': 'application/json'}
4546
data = urllib.parse.urlencode(values).encode(encoding='ascii')
4647
try:
47-
response = urllib.request.urlopen(urllib.request.Request(url, data, headers=headers))
48+
context = ssl.create_default_context(cafile=certifi.where())
49+
response = urllib.request.urlopen(urllib.request.Request(url, data, headers=headers), context=context)
4850
except urllib.error.HTTPError as e:
4951
_show_json_error(e.read())
5052
return

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@
134134
"requests",
135135
"future",
136136
"lit==0.11.1",
137+
"certifi"
137138
],
138139

139140
ext_modules=[cPerf],

0 commit comments

Comments
 (0)