ssl encrypt and decrypt works now

This commit is contained in:
2025-03-19 21:24:33 +01:00
parent 1667682c9d
commit 13832d916f
9 changed files with 176 additions and 75 deletions

View File

@ -3,23 +3,18 @@
import os
from subprocess import check_call
import shutil
from pathlib import Path
import shutil
uname = Path('/tmp/.loguser')
with open(uname, 'r') as f:
logname = f.readline()
''' Dirname "tlecdewg" = Tunnel Encrypt Decrypt Wireguard '''
dirname = Path('/tmp/tlecdcwg/')
keyfile = '/usr/local/etc/ssl/pwgk.pem'
logname = os.getlogin()
''' Remove the folder when it is there '''
if os.path.exists(str(dirname)):
shutil.rmtree(str(dirname))
os.mkdir(dirname)
shutil.chown(dirname, 1000, 1000)
tl = os.listdir(str(dirname))
dirname2 = '/home/' + logname + '/.config/wire_py/'
dirname2 = ('/home/' + logname + '/.config/wire_py/')
detl = os.listdir(dirname2)
os.chdir(dirname2)
detl.remove('keys')
@ -30,9 +25,4 @@ if os.path.exists(dirname2 + 'pbwgk.pem'):
tlname2 = detunnels[:-4] + '.conf'
extpath = str(dirname) + '/' + tlname2
check_call(['openssl', 'pkeyutl', '-decrypt', '-inkey', keyfile, '-in', detunnels, '-out', extpath])
def create_pub_key():
pth_with_keyname = '/home/' + logname + '/.config/wire_py/pbwgk.pem'
check_call(['openssl', 'rsa', '-in', keyfile, '-out', pth_with_keyname, '-outform', 'PEM', '-pubout'])
shutil.chown(pth_with_keyname, 1000, 1000)
shutil.chown(extpath, 1000, 1000)