move cert directory to ~/.local/share/gajim/certs

This commit is contained in:
Zhenchao Li 2010-08-10 21:10:45 +08:00
parent 91a68d30be
commit 42f6580d1d
3 changed files with 12 additions and 6 deletions

View File

@ -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):

View File

@ -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')))

View File

@ -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():