create certs path if it does not exist

This commit is contained in:
Zhenchao Li 2010-08-08 21:55:32 +08:00
parent 02c1eaf930
commit e810727002
2 changed files with 9 additions and 1 deletions

View File

@ -29,6 +29,7 @@ import stat
from common import gajim
import logger
from common import jingle_xtls
# DO NOT MOVE ABOVE OF import gajim
import sqlite3 as sqlite
@ -267,6 +268,7 @@ def check_and_possibly_create_paths():
MY_DATA = configpaths.gajimpaths['MY_DATA']
MY_CONFIG = configpaths.gajimpaths['MY_CONFIG']
MY_CACHE = configpaths.gajimpaths['MY_CACHE']
XTLS_CERTS = os.path.expanduser('~/certs/')
if not os.path.exists(MY_DATA):
create_path(MY_DATA)
@ -333,6 +335,13 @@ def check_and_possibly_create_paths():
print _('Gajim will now exit')
sys.exit()
if not os.path.exists(XTLS_CERTS):
create_path(XTLS_CERTS)
if not (os.path.exists(os.path.join(XTLS_CERTS, jingle_xtls.SELF_SIGNED_CERTIFICATE + '.cert')) and
os.path.exist(os.path.join(XTLS_CERTS, jingle_xtls.SELF_SIGNED_CERTIFICATE + '.pkey'))):
jingle_xtls.make_certs(XTLS_CERTS + jingle_xtls.SELF_SIGNED_CERTIFICATE, 'gajim')
def create_path(directory):
print _('creating %s directory') % directory
os.mkdir(directory, 0700)

View File

@ -86,7 +86,6 @@ def get_context(fingerprint, verify_cb=None):
ctx.use_privatekey_file (os.path.expanduser('~/certs/' + SELF_SIGNED_CERTIFICATE + '.pkey'))
ctx.use_certificate_file(os.path.expanduser('~/certs/' + SELF_SIGNED_CERTIFICATE + '.cert'))
# ctx.load_verify_locations(os.path.expanduser('~/certs/CA.cert'))
store = ctx.get_cert_store()
for f in os.listdir(os.path.expanduser('~/certs/')):
load_cert_file(os.path.join(os.path.expanduser('~/certs'), f), store)