runtime/Stunnel.py
changeset 2321 0a3103cd825d
child 2323 33a0dbabccd3
equal deleted inserted replaced
2320:dd959601e67a 2321:0a3103cd825d
       
     1 import os
       
     2 from binascii import hexlify
       
     3 
       
     4 restart_stunnel_cmdline = ["/etc/init.d/S50stunnel","restart"]
       
     5 
       
     6 def pskgen(ID, pskpath):
       
     7     secretstring = hexlify(os.urandom(256))
       
     8     pskstring = ID+":"+secretstring
       
     9     with open(pskpath, 'w') as f:
       
    10         f.write(pskstring)
       
    11     call(restart_stunnel_cmdline)
       
    12 
       
    13 def ensurepsk(ID, pskpath):
       
    14     # check if already there
       
    15     if not os.path.exists(pskpath):
       
    16         # create if needed
       
    17         pskgen(IS, pskpath)
       
    18