ssl encrypt and decrypt works now
This commit is contained in:
@ -5,35 +5,45 @@ import os
|
||||
from subprocess import check_call
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
from ssl_decrypt import create_pub_key
|
||||
|
||||
logname = os.getlogin()
|
||||
keyfile = Path('/home/', logname) / '.config/wire_py/pbwgk.pem'
|
||||
uname = Path('/tmp/.loguser')
|
||||
|
||||
with open(uname, 'r') as f:
|
||||
logname = f.readline()
|
||||
|
||||
keyfile = Path(f'/home/{logname}/.config/wire_py/pbwgk.pem')
|
||||
dirname = Path('/tmp/tlecdcwg/')
|
||||
pkeyfile = '/usr/local/etc/ssl/pwgk.pem'
|
||||
|
||||
if not keyfile.is_file():
|
||||
create_pub_key()
|
||||
|
||||
else:
|
||||
|
||||
check_call(['openssl', 'rsa', '-in', pkeyfile, '-out', keyfile, '-outform', 'PEM', '-pubout'])
|
||||
shutil.chown(keyfile, 1000, 1000)
|
||||
|
||||
if dirname.exists():
|
||||
tl = os.listdir(dirname)
|
||||
print(tl)
|
||||
tl = os.listdir(str(dirname))
|
||||
cpth = str(keyfile)
|
||||
cryptfiles = cpth[:-9]
|
||||
|
||||
if keyfile.exists() and len(tl) != 0:
|
||||
for tunnels in tl:
|
||||
sourcetl = str(dirname) + '/' + tunnels
|
||||
tlname = cryptfiles + tunnels[:-5] + '.dat'
|
||||
check_call(['openssl', 'pkeyutl', '-encrypt', '-inkey', keyfile, '-pubin', '-in', sourcetl, '-out', tlname])
|
||||
|
||||
else:
|
||||
|
||||
if dirname.exists():
|
||||
tl = os.listdir(str(dirname))
|
||||
cpth = str(keyfile)
|
||||
cryptfiles = cpth[:-9]
|
||||
|
||||
if keyfile.exists() and len(tl) != 0:
|
||||
for tunnels in tl:
|
||||
sourcetl = str(dirname) + '/' + tunnels
|
||||
print(source)
|
||||
tlname = cryptfiles + tunnels[:-5] + '.dat'
|
||||
check_call(['openssl', 'pkeyutl', '-encrypt', '-inkey', keyfile, '-pubin', '-in', sourcetl, '-out', tlname])
|
||||
else:
|
||||
print('im else block')
|
||||
|
||||
#shutil.rmtree(dirname)
|
||||
else:
|
||||
print('im letzen else block')
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user