Browse Source

- always encrypt if we have a key

git-svn-id: file:///home/www/usr01/svn/gnuviechadmin/gnuviech.info/gnuviechadmin/trunk@232 a67ec6bc-e5d5-0310-a910-815c51eb3124
master
Jan Dittberner 14 years ago
parent
commit
732bb17fc5
  1. 14
      gnuviechadmin/backend/BackendEntity.py

14
gnuviechadmin/backend/BackendEntity.py

@ -71,8 +71,9 @@ class BackendEntity(object):
and signs it usign GnuPG. If a public key of the recipient is
available the mail is encrypted."""
plain = core.Data(text)
sig = core.Data()
cipher = core.Data()
c = core.Context()
c.set_armor(1)
signer = config.get('common', 'mailfrom')
rcpt = config.get('common', 'mailto')
c.signers_clear()
@ -83,7 +84,7 @@ class BackendEntity(object):
raise Exception("No secret keys for signing available for %s." % (
signer))
keylist = []
for key in [x for x in c.op_keylist_all(rcpt, 1)]:
for key in c.op_keylist_all(rcpt, 0):
valid = 0
subkey = key.subkeys
while subkey:
@ -96,13 +97,12 @@ class BackendEntity(object):
if valid:
keylist.append(key)
if keylist:
c.set_armor(1)
c.op_encrypt_sign(keylist, 1, plain, sig)
c.op_encrypt_sign(keylist, 1, plain, cipher)
else:
c.op_sign(plain, sig, mode.CLEAR)
sig.seek(0,0)
c.op_sign(plain, cipher, mode.CLEAR)
cipher.seek(0,0)
msg = MIMEText(sig.read())
msg = MIMEText(cipher.read())
msg['Subject'] = subject
msg['From'] = signer
msg['To'] = rcpt

Loading…
Cancel
Save