Use certifi on MacOS
Python 3.6 does not use the MacOS cert store anymore
This commit is contained in:
parent
5e712768cf
commit
395d24bee6
2 changed files with 7 additions and 5 deletions
|
@ -33,6 +33,7 @@
|
||||||
##
|
##
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
import random
|
import random
|
||||||
import socket
|
import socket
|
||||||
import operator
|
import operator
|
||||||
|
@ -49,7 +50,7 @@ from string import Template
|
||||||
from urllib.request import urlopen
|
from urllib.request import urlopen
|
||||||
from urllib.error import URLError
|
from urllib.error import URLError
|
||||||
|
|
||||||
if os.name == 'nt':
|
if sys.platform in ('win32', 'darwin'):
|
||||||
import certifi
|
import certifi
|
||||||
import OpenSSL.crypto
|
import OpenSSL.crypto
|
||||||
import nbxmpp
|
import nbxmpp
|
||||||
|
@ -1175,7 +1176,7 @@ class Connection(CommonConnection, ConnectionHandlers):
|
||||||
port = self._current_host['port']
|
port = self._current_host['port']
|
||||||
|
|
||||||
cacerts = ''
|
cacerts = ''
|
||||||
if os.name == 'nt':
|
if sys.platform in ('win32', 'darwin'):
|
||||||
cacerts = certifi.where()
|
cacerts = certifi.where()
|
||||||
mycerts = common.configpaths.get('MY_CACERTS')
|
mycerts = common.configpaths.get('MY_CACERTS')
|
||||||
tls_version = app.config.get_per('accounts', self.name, 'tls_version')
|
tls_version = app.config.get_per('accounts', self.name, 'tls_version')
|
||||||
|
@ -1374,7 +1375,7 @@ class Connection(CommonConnection, ConnectionHandlers):
|
||||||
url = 'https://%s/.well-known/posh/xmpp-client.json' % hostname
|
url = 'https://%s/.well-known/posh/xmpp-client.json' % hostname
|
||||||
|
|
||||||
cafile = None
|
cafile = None
|
||||||
if os.name == 'nt':
|
if sys.platform in ('win32', 'darwin'):
|
||||||
cafile = certifi.where()
|
cafile = certifi.where()
|
||||||
|
|
||||||
log.info('Request POSH from %s', url)
|
log.info('Request POSH from %s', url)
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
# along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
# along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
import threading
|
import threading
|
||||||
import ssl
|
import ssl
|
||||||
import urllib
|
import urllib
|
||||||
|
@ -35,7 +36,7 @@ from gajim.common.connection_handlers_events import HTTPUploadProgressEvent
|
||||||
from gajim.common.connection_handlers_events import MessageOutgoingEvent
|
from gajim.common.connection_handlers_events import MessageOutgoingEvent
|
||||||
from gajim.common.connection_handlers_events import GcMessageOutgoingEvent
|
from gajim.common.connection_handlers_events import GcMessageOutgoingEvent
|
||||||
|
|
||||||
if os.name == 'nt':
|
if sys.platform in ('win32', 'darwin'):
|
||||||
import certifi
|
import certifi
|
||||||
|
|
||||||
log = logging.getLogger('gajim.c.httpupload')
|
log = logging.getLogger('gajim.c.httpupload')
|
||||||
|
@ -300,7 +301,7 @@ class ConnectionHTTPUpload:
|
||||||
log.warning('CERT Verification disabled')
|
log.warning('CERT Verification disabled')
|
||||||
transfer = urlopen(request, timeout=30, context=context)
|
transfer = urlopen(request, timeout=30, context=context)
|
||||||
else:
|
else:
|
||||||
if os.name == 'nt':
|
if sys.platform in ('win32', 'darwin'):
|
||||||
transfer = urlopen(
|
transfer = urlopen(
|
||||||
request, cafile=certifi.where(), timeout=30)
|
request, cafile=certifi.where(), timeout=30)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Reference in a new issue