diff --git a/src/common/check_paths.py b/src/common/check_paths.py index 9d623e333..29c6846c6 100644 --- a/src/common/check_paths.py +++ b/src/common/check_paths.py @@ -339,7 +339,7 @@ def check_and_possibly_create_paths(): create_path(XTLS_CERTS) if not (os.path.exists(os.path.join(XTLS_CERTS, jingle_xtls.SELF_SIGNED_CERTIFICATE + '.cert')) and os.path.exists(os.path.join(XTLS_CERTS, jingle_xtls.SELF_SIGNED_CERTIFICATE + '.pkey'))): - jingle_xtls.make_certs(XTLS_CERTS + jingle_xtls.SELF_SIGNED_CERTIFICATE, 'gajim') + jingle_xtls.make_certs(os.path.join(XTLS_CERTS, jingle_xtls.SELF_SIGNED_CERTIFICATE), 'gajim') def create_path(directory): diff --git a/src/common/configpaths.py b/src/common/configpaths.py index 465e76676..8c2df8b58 100644 --- a/src/common/configpaths.py +++ b/src/common/configpaths.py @@ -140,7 +140,8 @@ class ConfigPaths: d = {'MY_DATA': '', 'LOG_DB': u'logs.db', 'MY_CACERTS': u'cacerts.pem', 'MY_EMOTS': u'emoticons', 'MY_ICONSETS': u'iconsets', - 'MY_MOOD_ICONSETS': u'moods', 'MY_ACTIVITY_ICONSETS': u'activities'} + 'MY_MOOD_ICONSETS': u'moods', 'MY_ACTIVITY_ICONSETS': u'activities', + 'MY_PEER_CERTS': u'certs'} for name in d: self.add(name, TYPE_DATA, windowsify(d[name])) @@ -150,6 +151,7 @@ class ConfigPaths: self.add(name, TYPE_CACHE, windowsify(d[name])) self.add('MY_CONFIG', TYPE_CONFIG, '') + self.add('MY_CERT', TYPE_CONFIG, 'localcert') basedir = fse(os.environ.get(u'GAJIM_BASEDIR', defs.basedir)) self.add('DATA', None, os.path.join(basedir, windowsify(u'data'))) diff --git a/src/common/jingle_xtls.py b/src/common/jingle_xtls.py index 3ca718fa3..ace3c1817 100644 --- a/src/common/jingle_xtls.py +++ b/src/common/jingle_xtls.py @@ -23,6 +23,9 @@ import common import gajim log = logging.getLogger('gajim.c.jingle_xtls') +from common import configpaths +gajimpath = configpaths.gajimpaths + PYOPENSSL_PRESENT = False try: @@ -36,7 +39,8 @@ if PYOPENSSL_PRESENT: from OpenSSL.SSL import Context from OpenSSL import crypto -CERTIFICATE_DIR = '~/certs/' +CERTIFICATE_DIR = gajimpath['MY_PEER_CERTS'] +print 'CERTIFICATE_DIR: ', CERTIFICATE_DIR SELF_SIGNED_CERTIFICATE = 'localcert' def default_callback(connection, certificate, error_num, depth, return_code): @@ -87,15 +91,15 @@ def get_context(fingerprint, verify_cb=None): elif fingerprint == 'client': ctx.set_verify(SSL.VERIFY_PEER, verify_cb or default_callback) - ctx.use_privatekey_file (os.path.expanduser(CERTIFICATE_DIR + SELF_SIGNED_CERTIFICATE + '.pkey')) - ctx.use_certificate_file(os.path.expanduser(CERTIFICATE_DIR + SELF_SIGNED_CERTIFICATE + '.cert')) + ctx.use_privatekey_file (os.path.expanduser(os.path.join(CERTIFICATE_DIR, SELF_SIGNED_CERTIFICATE) + '.pkey')) + ctx.use_certificate_file(os.path.expanduser(os.path.join(CERTIFICATE_DIR, SELF_SIGNED_CERTIFICATE) + '.cert')) store = ctx.get_cert_store() for f in os.listdir(os.path.expanduser(CERTIFICATE_DIR)): load_cert_file(os.path.join(os.path.expanduser(CERTIFICATE_DIR), f), store) return ctx def send_cert(con, jid_from, sid): - certpath = os.path.expanduser(CERTIFICATE_DIR + SELF_SIGNED_CERTIFICATE + '.cert') + certpath = os.path.expanduser(os.path.join(CERTIFICATE_DIR, SELF_SIGNED_CERTIFICATE) + '.cert') certfile = open(certpath, 'r') certificate = '' for line in certfile.readlines():